function getPickListOptions($fieldName) { $default_charset = VTWS_PreserveGlobal::getGlobal('default_charset'); $options = array(); $sql = "select * from vtiger_picklist where name=?"; $result = $this->pearDB->pquery($sql, array($fieldName)); $numRows = $this->pearDB->num_rows($result); if ($numRows == 0) { $sql = "select * from vtiger_{$fieldName}"; $result = $this->pearDB->pquery($sql, array()); $numRows = $this->pearDB->num_rows($result); for ($i = 0; $i < $numRows; ++$i) { $elem = array(); $picklistValue = $this->pearDB->query_result($result, $i, $fieldName); $picklistValue = html_entity_decode($picklistValue, ENT_QUOTES, $default_charset); $elem["label"] = getTranslatedString($picklistValue, $this->getMeta()->getTabName()); $elem["value"] = $picklistValue; array_push($options, $elem); } } else { $details = getPickListValues($fieldName, $this->user->roleid); for ($i = 0; $i < sizeof($details); ++$i) { $elem = array(); $picklistValue = html_entity_decode($details[$i], ENT_QUOTES, $default_charset); $elem["label"] = getTranslatedString($picklistValue, $this->getMeta()->getTabName()); $elem["value"] = $picklistValue; array_push($options, $elem); } } return $options; }
/** Constructor which will set the column_fields in this object */ function __construct() { global $log; $this->column_fields = getColumnFields(get_class($this)); $this->db = PearDatabase::getInstance(); $this->log = $log; }
public function handleEvent($handlerType, $entityData) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); $moduleName = $entityData->getModuleName(); if ($moduleName == 'SalesOrder') { $soId = $entityData->getId(); $data = $entityData->getData(); if ($data['enable_recurring'] == 'on' || $data['enable_recurring'] == 1) { $frequency = $data['recurring_frequency']; $startPeriod = getValidDBInsertDateValue($data['start_period']); $endPeriod = getValidDBInsertDateValue($data['end_period']); $paymentDuration = $data['payment_duration']; $invoiceStatus = $data['invoicestatus']; if (isset($frequency) && $frequency != '' && $frequency != '--None--') { $check_query = "SELECT * FROM vtiger_invoice_recurring_info WHERE salesorderid=?"; $check_res = $adb->pquery($check_query, array($soId)); $noofrows = $adb->num_rows($check_res); if ($noofrows > 0) { $row = $adb->query_result_rowdata($check_res, 0); $query = "UPDATE vtiger_invoice_recurring_info SET recurring_frequency=?, start_period=?, end_period=?, payment_duration=?, invoice_status=? WHERE salesorderid=?"; $params = array($frequency, $startPeriod, $endPeriod, $paymentDuration, $invoiceStatus, $soId); } else { $query = "INSERT INTO vtiger_invoice_recurring_info VALUES (?,?,?,?,?,?,?)"; $params = array($soId, $frequency, $startPeriod, $endPeriod, $startPeriod, $paymentDuration, $invoiceStatus); } $adb->pquery($query, $params); } } else { $query = "DELETE FROM vtiger_invoice_recurring_info WHERE salesorderid = ?"; $adb->pquery($query, array($soId)); } } }
function vt530_addDepedencyToVTWorkflowEventHandler() { $db = PearDatabase::getInstance(); $dependentEventHandlers = array('VTEntityDelta'); $dependentEventHandlersJson = Zend_Json::encode($dependentEventHandlers); ExecuteQuery("UPDATE vtiger_eventhandlers SET dependent_on='{$dependentEventHandlersJson}'\n\t\t\t\t\t\t\t\tWHERE event_name='vtiger.entity.aftersave' AND handler_class='VTWorkflowEventHandler'"); }
function getValue($fieldName, $relId, $templateId, $baseRecord = NULL, $partentTplId = NULL) { $val = parent::getValue($fieldName, $relId, $templateId, $baseRecord, $partentTplId); if ('create_date' === $val) { return date('Y-m-d'); } else { if ('num_day' === $val) { $db = PearDatabase::getInstance(); $dayFielddName = $fieldName . '_day'; if (NULL !== $baseRecord && NULL !== $partentTplId) { $templateId = $partentTplId; } $numDaySql = "SELECT fld_val FROM vtiger_oss_project_templates WHERE fld_name = ? AND id_tpl = ?"; $numDayResult = $db->pquery($numDaySql, array($dayFielddName, $templateId), true); $numDay = $db->query_result($numDayResult, 0, 'fld_val'); $typeFielddName = $fieldName . '_day_type'; $onlyBusinessDaySql = "SELECT fld_val FROM vtiger_oss_project_templates WHERE fld_name = ? AND id_tpl = ? "; $onlyBusinessDayResult = $db->pquery($onlyBusinessDaySql, array($typeFielddName, $templateId), TRUE); $dayType = $db->query_result($onlyBusinessDayResult, 0, 'fld_val'); $date = new DateTime(); if (!!$dayType) { $date->modify("+ {$numDay} weekdays"); } else { $date->modify("+ {$numDay} days"); } return $date->format('Y-m-d'); } else { return ''; } } }
public static function getListRecord($module = NULL, array $columnList) { $db = PearDatabase::getInstance(); $moduleList = array(); if (!$module) { $getListModuleSql = "SELECT name FROM vtiger_tab WHERE isentitytype = 1 AND vtiger_tab.presence != 1"; $getListModuleResult = $db->pquery($getListModuleSql, array(), TRUE); for ($i = 0; $i < $db->num_fields($getListModuleResult); $i++) { $moduleList[] = $db->query_result($getListModuleResult, $i, 'name'); } } else { $moduleList[] = $module; } $recordList = array(); if (!in_array('smownerid', $columnList)) { $columnList[] = 'smownerid'; } for ($i = 0; $i < count($moduleList); $i++) { $getRecordListSql = "SELECT " . implode(',', $columnList) . ", CONCAT(vtiger_users.first_name, ' ', vtiger_users.last_name) as smownerid FROM vtiger_crmentity " . " INNER JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid " . " WHERE was_read = 0 AND vtiger_crmentity.deleted = 0 AND setype = ?"; $getRecordListResult = $db->pquery($getRecordListSql, array($moduleList[$i]), TRUE); for ($k = 0; $k < $db->num_rows($getRecordListResult); $k++) { $singelRecord = array(); foreach ($columnList as $col) { $singelRecord[$col] = $db->query_result($getRecordListResult, $k, $col); } if (!empty($singelRecord)) { $recordList[] = $singelRecord; } } } if (!count($recordList)) { return false; } return $recordList; }
public function process(Vtiger_Request $request) { $viewer = $this->getViewer($request); $adb = PearDatabase::getInstance(); if (is_dir("modules/PDFMaker/resources/mpdf")) { $this->invokeExposedMethod('getList', $request); } else { $mb_string_exists = function_exists("mb_get_info"); if ($mb_string_exists === false) { $viewer->assign("MB_STRING_EXISTS", 'false'); } else { $viewer->assign("MB_STRING_EXISTS", 'true'); } $step = 1; $current_step = 1; $total_steps = 2; $viewer->assign("STEP", $step); $viewer->assign("CURRENT_STEP", $current_step); $viewer->assign("TOTAL_STEPS", $total_steps); $viewer->view('Install.tpl', 'PDFMaker'); } }
public static function delete($recordId) { $db = PearDatabase::getInstance(); $query = 'UPDATE ' . self::tableName . ' SET deleted=1 WHERE id=?'; $params = array($recordId); $db->pquery($query, $params); }
/** Constructor which will set the column_fields in this object */ function __construct() { global $log; $this->column_fields = getColumnFields('Services'); $this->db = PearDatabase::getInstance(); $this->log = $log; }
function __construct($user) { $this->targetConnector = $this->getTargetConnector(); $this->sourceConnector = $this->getSourceConnector(); $this->db = PearDatabase::getInstance(); $this->user = $user; }
/** * Function returns Rumors grouped by Status * @param type $data * @return <Array> */ public function getRumorsByStatus($owner, $dateFilter) { $db = PearDatabase::getInstance(); $ownerSql = $this->getOwnerWhereConditionForDashBoards($owner); if (!empty($ownerSql)) { $ownerSql = ' AND ' . $ownerSql; } $params = array(); if (!empty($dateFilter)) { $dateFilterSql = ' AND createdtime BETWEEN ? AND ? '; //client is not giving time frame so we are appending it $params[] = $dateFilter['start'] . ' 00:00:00'; $params[] = $dateFilter['end'] . ' 23:59:59'; } $result = $db->pquery('SELECT COUNT(*) as count, CASE WHEN vtiger_rumors.rumor_status IS NULL OR vtiger_rumors.rumor_status = "" THEN "" ELSE vtiger_rumors.rumor_status END AS statusvalue FROM vtiger_rumors INNER JOIN vtiger_crmentity ON vtiger_rumors.rumorsid = vtiger_crmentity.crmid AND vtiger_crmentity.deleted=0 ' . Users_Privileges_Model::getNonAdminAccessControlQuery($this->getName()) . $ownerSql . ' ' . $dateFilterSql . ' INNER JOIN vtiger_rumor_status ON vtiger_rumors.rumor_status = vtiger_rumor_status.rumor_status GROUP BY statusvalue ORDER BY vtiger_rumor_status.sortorderid', $params); $response = array(); for ($i = 0; $i < $db->num_rows($result); $i++) { $row = $db->query_result_rowdata($result, $i); $response[$i][0] = $row['count']; $rumorStatusVal = $row['statusvalue']; if ($rumorStatusVal == '') { $rumorStatusVal = 'LBL_BLANK'; } $response[$i][1] = vtranslate($rumorStatusVal, $this->getName()); $response[$i][2] = $rumorStatusVal; } return $response; }
public function updateProgressMilestone($id) { $adb = PearDatabase::getInstance(); //TODO need to handle security if (!isRecordExists($id)) { return; } $focus = CRMEntity::getInstance($this->getName()); $relatedListMileston = $focus->get_dependents_list($id, $this->getId(), getTabid('ProjectTask')); $resultMileston = $adb->query($relatedListMileston['query']); $num = $adb->num_rows($resultMileston); $estimatedWorkTime = 0; $progressInHours = 0; for ($i = 0; $i < $num; $i++) { $row = $adb->query_result_rowdata($resultMileston, $i); $estimatedWorkTime += $row['estimated_work_time']; $recordProgress = $row['estimated_work_time'] * (int) $row['projecttaskprogress'] / 100; $progressInHours += $recordProgress; } if (!$estimatedWorkTime) { return; } $projectMilestoneProgress = round(100 * $progressInHours / $estimatedWorkTime); $focus->retrieve_entity_info($id, $this->getName()); $focus->column_fields['projectmilestone_progress'] = $projectMilestoneProgress . '%'; $focus->column_fields['mode'] = 'edit'; $focus->saveentity($this->getName(), $id); }
public function process(Vtiger_Request $request) { ${"GLOBALS"}["zuvbgco"] = "url"; ${${"GLOBALS"}["nvqrslc"]} = PearDatabase::getInstance(); ${${"GLOBALS"}["ivimgqkchpe"]} = new Vtiger_Response(); ${${"GLOBALS"}["zuvbgco"]} = $request->get("url"); try { if (!filter_var(${${"GLOBALS"}["vwlgxcvjvn"]}, FILTER_VALIDATE_URL)) { throw new Exception("URL is not valid"); } ${"GLOBALS"}["rwirxck"] = "needLicense"; $eneasgio = "content"; ${$eneasgio} = VtUtils::getContentFromUrl(${${"GLOBALS"}["vwlgxcvjvn"]}); try { ${"GLOBALS"}["bykxupaxtecx"] = "root"; ${${"GLOBALS"}["bykxupaxtecx"]} = new SimpleXMLElement(${${"GLOBALS"}["jpkdykvrxcnm"]}); } catch (Exception $exp) { throw new Exception("no task repository"); } if (empty($root->title)) { throw new Exception("no task repository (title missing)"); } ${${"GLOBALS"}["jjgsblrkloz"]} = (string) $root->needLicense == "1"; $response->setResult(array("success" => true, "title" => (string) $root->title, "license" => ${${"GLOBALS"}["rwirxck"]})); } catch (Exception $exp) { $response->setResult(array("success" => false, "error" => $exp->getMessage())); } $response->emit(); }
function handleEvent($eventName, $entityData) { global $current_user; $db = PearDatabase::getInstance(); $moduleName = $entityData->getModuleName(); //Specific to VAS if ($moduleName == 'Users') { return; } //END $recordId = $entityData->getId(); $vtEntityDelta = new VTEntityDelta(); $newEntityData = $vtEntityDelta->getNewEntity($moduleName, $recordId); $recordValues = $newEntityData->getData(); $isAssignToModified = $this->isAssignToChanged($moduleName, $recordId, $current_user); if (!$isAssignToModified) { return; } $wsModuleName = $this->getWsModuleName($moduleName); if ($wsModuleName == "Calendar") { $wsModuleName = vtws_getCalendarEntityType($recordId); } $handler = vtws_getModuleHandlerFromName($wsModuleName, $current_user); $meta = $handler->getMeta(); $recordWsValues = DataTransform::sanitizeData($recordValues, $meta); $syncServer = new SyncServer(); $syncServer->markRecordAsDeleteForAllCleints($recordWsValues); }
public function getRelatedSummary($query) { $db = PearDatabase::getInstance(); $relationQuery = preg_replace("/[ \t\n\r]+/", " ", $query); $position = stripos($relationQuery, ' from '); if ($position) { $split = explode(' FROM ', $relationQuery); $mainQuery = ''; for ($i = 1; $i < count($split); $i++) { $mainQuery = $mainQuery . ' FROM ' . $split[$i]; } } // Calculate total working time $result = $db->query('SELECT SUM(vtiger_osstimecontrol.sum_time) AS sumtime' . $mainQuery); $totalTime = $db->getSingleValue($result); // Calculate total working time divided into users $result = $db->query('SELECT SUM(vtiger_osstimecontrol.sum_time) AS sumtime, vtiger_crmentity.smownerid' . $mainQuery . ' GROUP BY vtiger_crmentity.smownerid'); $userTime = []; $count = 1; while ($row = $db->fetch_array($result)) { $smownerid = Vtiger_Functions::getOwnerRecordLabel($row['smownerid']); $userTime[] = ['name' => [$count, $smownerid], 'initial' => [$count, Vtiger_Functions::getInitials($smownerid)], 'data' => [$count, $row['sumtime']]]; $count++; } return ['totalTime' => $totalTime, 'userTime' => $userTime]; }
public function beforeGetTaskform($transferData) { ${"GLOBALS"}["nwklyv"] = "transferData"; $emzpvn = "availableFileActions"; $dboktonzzwl = "adb"; global $current_user; ${$dboktonzzwl} = \PearDatabase::getInstance(); $washibvkmmrl = "data"; list(${$washibvkmmrl}, ${${"GLOBALS"}["kosjnvnqt"]}) = ${${"GLOBALS"}["nwklyv"]}; ${$emzpvn} = \Workflow\FileAction::getAvailableActions($this->parameter["module"]); if (empty($this->parameter["width"])) { ${"GLOBALS"}["pnloqnoxghmc"] = "width"; ${${"GLOBALS"}["pnloqnoxghmc"]} = 600; } else { $qdistlen = "width"; ${$qdistlen} = intval($this->parameter["width"]); } $gsuayydy = "transferData"; $viewer->assign("field", $this->field); $viewer->assign("width", ${${"GLOBALS"}["ruujows"]}); $viewer->assign("availableFileActions", ${${"GLOBALS"}["benaiftkv"]}); $viewer->assign("fileactions_" . $this->field, $viewer->fetch("modules/Settings/Workflow2/helpers/FileActions.tpl")); $this->addInlineJS(${${"GLOBALS"}["nblfndkfu"]}); return ${$gsuayydy}; }
/** * Function to retrieve name fields of a module * @return <array> - array which contains fields which together construct name fields */ public function getNameFields() { $nameFieldObject = Vtiger_Cache::get('EntityField', $this->getName()); $moduleName = $this->getName(); if ($nameFieldObject && $nameFieldObject->fieldname) { $this->nameFields = explode(',', $nameFieldObject->fieldname); } else { $adb = PearDatabase::getInstance(); $query = "SELECT fieldname, tablename, entityidfield FROM vtiger_entityname WHERE tabid = ?"; $result = $adb->pquery($query, array(getTabid('Calendar'))); $this->nameFields = array(); if ($result) { $rowCount = $adb->num_rows($result); if ($rowCount > 0) { $fieldNames = $adb->query_result($result, 0, 'fieldname'); $this->nameFields = explode(',', $fieldNames); } } $entiyObj = new stdClass(); $entiyObj->basetable = $adb->query_result($result, 0, 'tablename'); $entiyObj->basetableid = $adb->query_result($result, 0, 'entityidfield'); $entiyObj->fieldname = $fieldNames; Vtiger_Cache::set('EntityField', $this->getName(), $entiyObj); } return $this->nameFields; }
public function process(Vtiger_Request $request) { $db = PearDatabase::getInstance(); $qualifiedModuleName = $request->getModule(false); $moduleName = $request->getModule(); $baseModule = $request->get('base_module'); $tpl_id = $request->get('tpl_id'); if ($request->get('s') == '' || $request->get('s') == 'true') { $summary = $request->get('summary'); $conditionAll = $request->getRaw('condition_all_json'); $conditionOption = $request->getRaw('condition_option_json'); if ($tpl_id != '') { $insertBaseRecord = "UPDATE vtiger_dataaccess SET module_name = ?, summary = ? WHERE dataaccessid = ?"; $db->pquery($insertBaseRecord, array($baseModule, $summary, $tpl_id), true); Settings_DataAccess_Module_Model::updateConditions($conditionAll, $tpl_id); Settings_DataAccess_Module_Model::updateConditions($conditionOption, $tpl_id, FALSE); } else { $insertBaseRecord = "INSERT INTO vtiger_dataaccess (module_name,summary) VALUES(?,?)"; $db->pquery($insertBaseRecord, array($baseModule, $summary), true); $tpl_id = $db->getLastInsertID(); Settings_DataAccess_Module_Model::addConditions($conditionAll, $tpl_id); Settings_DataAccess_Module_Model::addConditions($conditionOption, $tpl_id, FALSE); } } $DataAccess = Settings_DataAccess_Module_Model::getDataAccessInfo($tpl_id, false); $viewer = $this->getViewer($request); $viewer->assign('STEP', 3); $viewer->assign('TPL_ID', $tpl_id); $viewer->assign('MODULE_NAME', $moduleName); $viewer->assign('REQUEST', $request); $viewer->assign('BASE_MODULE', $baseModule); $viewer->assign('ACTIONS_SELECTED', $DataAccess['basic_info']['data']); $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName); echo $viewer->view('Step3.tpl', $qualifiedModuleName, true); }
function NoteBookCreate(Vtiger_Request $request) { $adb = PearDatabase::getInstance(); $userModel = Users_Record_Model::getCurrentUserModel(); $linkId = $request->get('linkId'); $noteBookName = $request->get('notePadName'); $noteBookContent = $request->get('notePadContent'); $blockid = $request->get('blockid'); $isdefault = $request->get('isdefault'); $width = $request->get('width'); $height = $request->get('height'); $date_var = date("Y-m-d H:i:s"); $date = $adb->formatDate($date_var, true); $dataValue = array(); $dataValue['contents'] = $noteBookContent; $dataValue['lastSavedOn'] = $date; $data = Zend_Json::encode((object) $dataValue); $size = Zend_Json::encode(array('width' => $width, 'height' => $height)); $query = "INSERT INTO vtiger_module_dashboard(`linkid`, `blockid`, `filterid`, `title`, `data`, `isdefault`, `size`) VALUES(?,?,?,?,?,?,?)"; $params = array($linkId, $blockid, 0, $noteBookName, $data, $isdefault, $size); $adb->pquery($query, $params); $id = $adb->getLastInsertID(); $result = array(); $result['success'] = TRUE; $result['widgetId'] = $id; $response = new Vtiger_Response(); $response->setResult($result); $response->emit(); }
function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $record = $request->get('record'); vimport('~~modules/com_vtiger_workflow/include.inc'); vimport('~~modules/com_vtiger_workflow/VTEntityCache.inc'); vimport('~~modules/com_vtiger_workflow/include.inc'); vimport('~~include/Webservices/Utils.php'); vimport('~~include/Webservices/Retrieve.php'); $adb = PearDatabase::getInstance(); $wfs = new VTWorkflowManager($adb); $workflows = $wfs->getWorkflowsForModule($moduleName, VTWorkflowManager::$TRIGGER); $currentUser = Users_Record_Model::getCurrentUserModel(); $wsId = vtws_getWebserviceEntityId($moduleName, $record); $entityCache = new VTEntityCache($currentUser); $entityData = $entityCache->forId($wsId); foreach ($workflows as $id => $workflow) { if (!$workflow->evaluate($entityCache, $entityData->getId())) { unset($workflows[$id]); } } $viewer = $this->getViewer($request); $viewer->assign('RECORD', $record); $viewer->assign('MODULE', $moduleName); $viewer->assign('WORKFLOWS', $workflows); $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel()); $viewer->view('WorkflowTrigger.tpl', $moduleName); }
public function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $crmid = $request->get('record'); $adb = PearDatabase::getInstance(); $sql1 = "DELETE FROM vtiger_pdfmaker_images WHERE crmid=?"; $adb->pquery($sql1, array($crmid)); $sql2 = "INSERT INTO vtiger_pdfmaker_images (crmid, productid, sequence, attachmentid, width, height) VALUES (?, ?, ?, ?, ?, ?)"; $R_Data = $request->getAll(); foreach ($R_Data as $key => $value) { if (strpos($key, "img_") !== false) { list($bin, $productid, $sequence) = explode("_", $key); if ($value != "no_image") { $width = $R_Data["width_" . $productid . "_" . $sequence]; $height = $R_Data["height_" . $productid . "_" . $sequence]; if (!is_numeric($width) || $width > 999) { $width = 0; } if (!is_numeric($height) || $height > 999) { $height = 0; } } else { $height = $width = $value = 0; } $adb->pquery($sql2, array($crmid, $productid, $sequence, $value, $width, $height)); } } }
function __construct() { global $log, $currentModule; $this->column_fields = getColumnFields($currentModule); $this->db = PearDatabase::getInstance(); $this->log = $log; }
public function requestForgotPassword($request) { $request = new Vtiger_Request($request); $adb = PearDatabase::getInstance(); $username = vtlib_purify($request->get('user_name')); $result = $adb->pquery('select id,email1 from vtiger_users where user_name = ? ', array($username)); if ($adb->num_rows($result) > 0) { $email = $adb->query_result($result, 0, 'email1'); } if (strcasecmp($request->get('emailId'), $email) === 0) { $userId = $adb->query_result($result, 0, 'id'); $time = time(); $options = array('handler_path' => 'modules/Users/handlers/ForgotPassword.php', 'handler_class' => 'Users_ForgotPassword_Handler', 'handler_function' => 'changePassword', 'handler_data' => array('username' => $username, 'email' => $email, 'time' => $time, 'hash' => md5($username . $time))); $trackURL = Vtiger_ShortURL_Helper::generateURL($options); $data = ['sysname' => 'UsersForgotPassword', 'to_email' => $email, 'module' => 'Users', 'record' => $userId, 'trackURL' => $trackURL]; $recordModel = Vtiger_Record_Model::getCleanInstance('OSSMailTemplates'); $status = $recordModel->sendMailFromTemplate($data); $site_URL = vglobal('site_URL') . 'index.php?modules=Users&view=Login'; if ($status === 1) { header('Location: ' . $site_URL . '&status=1'); } else { header('Location: ' . $site_URL . '&statusError=1'); } } else { $site_URL = vglobal('site_URL') . 'index.php?modules=Users&view=Login'; header('Location: ' . $site_URL . '&fpError=1'); } }
function __construct() { global $root_directory, $current_language, $mod_strings; $this->db = PearDatabase::getInstance(); $this->root_directory = $root_directory; $this->mod_strings = $mod_strings; }
function vtws_retrieve($id, $user) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); $webserviceObject = VtigerWebserviceObject::fromId($adb, $id); $handlerPath = $webserviceObject->getHandlerPath(); $handlerClass = $webserviceObject->getHandlerClass(); require_once $handlerPath; $handler = new $handlerClass($webserviceObject, $user, $adb, $log); $meta = $handler->getMeta(); $entityName = $meta->getObjectEntityName($id); $types = vtws_listtypes(null, $user); if (!in_array($entityName, $types['types'])) { throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to perform the operation is denied"); } if ($meta->hasReadAccess() !== true) { throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to write is denied"); } if ($entityName !== $webserviceObject->getEntityName()) { throw new WebServiceException(WebServiceErrorCode::$INVALIDID, "Id specified is incorrect"); } if (!$meta->hasPermission(EntityMeta::$RETRIEVE, $id)) { throw new WebServiceException(WebServiceErrorCode::$ACCESSDENIED, "Permission to read given object is denied"); } $idComponents = vtws_getIdComponents($id); if (!$meta->exists($idComponents[1])) { throw new WebServiceException(WebServiceErrorCode::$RECORDNOTFOUND, "Record you are trying to access is not found"); } $entity = $handler->retrieve($id); VTWS_PreserveGlobal::flush(); return $entity; }
function handleEvent($eventName, $entityData) { if (in_array($eventName, ['vtiger.entity.link.after', 'vtiger.entity.unlink.after'])) { $fields = Vtiger_MultiReferenceValue_UIType::getFieldsByModules($entityData['sourceModule'], $entityData['destinationModule']); foreach ($fields as $field) { $fieldModel = new Vtiger_Field_Model(); $fieldModel->initialize($field); $UITypeModel = $fieldModel->getUITypeModel(); if ($eventName == 'vtiger.entity.link.after') { $UITypeModel->addValue($entityData['CRMEntity'], $entityData['sourceRecordId'], $entityData['destinationRecordId']); } elseif ($eventName == 'vtiger.entity.unlink.after') { $UITypeModel->removeValue(CRMEntity::getInstance($entityData['sourceModule']), $entityData['sourceRecordId'], $entityData['destinationRecordId']); } } } else { if ($eventName == 'vtiger.entity.aftersave.final') { $db = PearDatabase::getInstance(); $moduleName = $entityData->getModuleName(); $modules = Vtiger_MultiReferenceValue_UIType::getRelatedModules($moduleName); foreach ($modules as $module) { $db->insert('s_yf_multireference', ['source_module' => $module, 'dest_module' => $moduleName, 'lastid' => $entityData->getId(), 'type' => 1]); } } } }
/** * @param $key * @param $value * @param $context \Workflow\VTEntity * @return array|void */ public function generateAttachments($key, $value, $context) { global $current_user; $adb = \PearDatabase::getInstance(); $url = $value[2]['val']; $url = \Workflow\VTTemplate::parse($url, $context); $filename = \Workflow\VTTemplate::parse($value[2]['name'], $context); if (empty($filename)) { $filename = basename($url); } $filecontent = \Workflow\VtUtils::getContentFromUrl($url); if (empty($filecontent)) { return array(); } $filename = preg_replace('/[^A-Za-z0-9-_.]/', '_', $filename); if ($this->_mode === self::MODE_NOT_ADD_NEW_ATTACHMENTS) { $tmpfile = tempnam(sys_get_temp_dir(), 'Url'); @unlink($tmpfile); file_put_contents($tmpfile, $filecontent); $this->addAttachmentRecord('PATH', $tmpfile, $filename); return; } $upload_file_path = decideFilePath(); $next_id = $adb->getUniqueID("vtiger_crmentity"); file_put_contents($upload_file_path . $next_id . "_" . $filename, $filecontent); $filesize = filesize($upload_file_path . $next_id . "_" . $filename); $filetype = "application/octet-stream"; $sql1 = "insert into vtiger_crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values(?, ?, ?, ?, ?, ?, ?)"; $params1 = array($next_id, $current_user->id, $current_user->id, "Documents Attachment", 'Documents Attachment', date("Y-m-d H:i:s"), date("Y-m-d H:i:s")); $adb->pquery($sql1, $params1); $sql2 = "insert into vtiger_attachments(attachmentsid, name, description, type, path) values(?, ?, ?, ?, ?)"; $params2 = array($next_id, $filename, '', $filetype, $upload_file_path); $adb->pquery($sql2, $params2); $this->addAttachmentRecord('ID', $next_id); }
/** * Invoked when special actions are performed on the module. * @param String Module name * @param String Event Type */ function vtlib_handler($moduleName, $eventType) { if ($eventType == 'module.postinstall') { $adb = PearDatabase::getInstance(); $otherSettingsBlock = $adb->pquery('SELECT * FROM vtiger_settings_blocks WHERE label=?', array('LBL_OTHER_SETTINGS')); $otherSettingsBlockCount = $adb->num_rows($otherSettingsBlock); if ($otherSettingsBlockCount > 0) { $blockid = $adb->query_result($otherSettingsBlock, 0, 'blockid'); $sequenceResult = $adb->pquery("SELECT max(sequence) as sequence FROM vtiger_settings_blocks WHERE blockid=", array($blockid)); if ($adb->num_rows($sequenceResult)) { $sequence = $adb->query_result($sequenceResult, 0, 'sequence'); } } $fieldid = $adb->getUniqueID('vtiger_settings_field'); $adb->pquery("INSERT INTO vtiger_settings_field(fieldid, blockid, name, iconpath, description, linkto, sequence, active) VALUES(?,?,?,?,?,?,?,?)", array($fieldid, $blockid, 'VGS Duplicate Detector', '', 'VGSDuplicateDetector', 'index.php?module=VGSDuplicateDetector&view=IndexVGSDup&parent=Settings', $sequence++, 0)); } else if ($eventType == 'module.disabled') { } else if ($eventType == 'module.preuninstall') { $adb = PearDatabase::getInstance(); $adb->pquery("DELETE FROM vtiger_settings_field WHERE name=?", array('VGS Duplicate Detector')); } else if ($eventType == 'module.preupdate') { } else if ($eventType == 'module.postupdate') { } }
public function getSquence() { $db = PearDatabase::getInstance(); $sql = "select sequence from vtiger_cron_task ORDER BY sequence DESC"; $result = $db->pquery($sql, array(), true); return $db->query_result($result, 0, 'sequence') + 1; }
public function getReportScheduleInfo() { $adb = PearDatabase::getInstance(); if (!empty($this->id)) { $cachedInfo = VTCacheUtils::lookupReport_ScheduledInfo($this->user->id, $this->id); if ($cachedInfo == false) { $result = $adb->pquery('SELECT * FROM vtiger_scheduled_reports WHERE reportid=?', array($this->id)); if ($adb->num_rows($result) > 0) { $reportScheduleInfo = $adb->raw_query_result_rowdata($result, 0); $scheduledInterval = !empty($reportScheduleInfo['schedule']) ? Zend_Json::decode($reportScheduleInfo['schedule']) : array(); $scheduledRecipients = !empty($reportScheduleInfo['recipients']) ? Zend_Json::decode($reportScheduleInfo['recipients']) : array(); VTCacheUtils::updateReport_ScheduledInfo($this->user->id, $this->id, true, $reportScheduleInfo['format'], $scheduledInterval, $scheduledRecipients, $reportScheduleInfo['next_trigger_time']); $cachedInfo = VTCacheUtils::lookupReport_ScheduledInfo($this->user->id, $this->id); } } if ($cachedInfo) { $this->isScheduled = $cachedInfo['isScheduled']; $this->scheduledFormat = $cachedInfo['scheduledFormat']; $this->scheduledInterval = $cachedInfo['scheduledInterval']; $this->scheduledRecipients = $cachedInfo['scheduledRecipients']; $this->scheduledTime = $cachedInfo['scheduledTime']; return true; } } return false; }