Ejemplo n.º 1
0
 /**
  * Function to get relation query for particular module with function name
  * @param <record> $recordId
  * @param <String> $functionName
  * @param Vtiger_Module_Model $relatedModule
  * @return <String>
  */
 public function getRelationQuery($recordId, $functionName, $relatedModule)
 {
     $relatedModuleName = $relatedModule->getName();
     $focus = CRMEntity::getInstance($this->getName());
     $focus->id = $recordId;
     $result = $focus->{$functionName}($recordId, $this->getId(), $relatedModule->getId());
     $query = $result['query'] . ' ' . $this->getSpecificRelationQuery($relatedModuleName);
     $nonAdminQuery = $this->getNonAdminAccessControlQueryForRelation($relatedModuleName);
     //modify query if any module has summary fields, those fields we are displayed in related list of that module
     $relatedListFields = $relatedModule->getConfigureRelatedListFields();
     if ($relatedModuleName == 'Documents') {
         $relatedListFields['filelocationtype'] = 'filelocationtype';
         $relatedListFields['filestatus'] = 'filestatus';
     }
     if (count($relatedListFields) > 0) {
         $currentUser = Users_Record_Model::getCurrentUserModel();
         $queryGenerator = new QueryGenerator($relatedModuleName, $currentUser);
         $queryGenerator->setFields($relatedListFields);
         $selectColumnSql = $queryGenerator->getSelectClauseColumnSQL();
         $newQuery = spliti('FROM', $query);
         $selectColumnSql = 'SELECT DISTINCT vtiger_crmentity.crmid,' . $selectColumnSql;
         $query = $selectColumnSql . ' FROM ' . $newQuery[1];
     }
     if ($nonAdminQuery) {
         $query = appendFromClauseToQuery($query, $nonAdminQuery);
     }
     return $query;
 }
Ejemplo n.º 2
0
 /**
  * Function to get relation query for particular module with function name
  * @param <record> $recordId
  * @param <String> $functionName
  * @param Vtiger_Module_Model $relatedModule
  * @return <String>
  */
 public function getRelationQuery($recordId, $functionName, $relatedModule, $relationModel = false)
 {
     $relatedModuleName = $relatedModule->getName();
     $focus = CRMEntity::getInstance($this->getName());
     $focus->id = $recordId;
     $result = $focus->{$functionName}($recordId, $this->getId(), $relatedModule->getId());
     $query = $result['query'] . ' ' . $this->getSpecificRelationQuery($relatedModuleName);
     //modify query if any module has summary fields, those fields we are displayed in related list of that module
     $relatedListFields = array();
     if ($relationModel) {
         $relatedListFields = $relationModel->getRelationFields(true, true);
     }
     if (count($relatedListFields) == 0) {
         $relatedListFields = $relatedModule->getConfigureRelatedListFields();
         if ($relatedModuleName == 'Documents') {
             $relatedListFields['filelocationtype'] = 'filelocationtype';
             $relatedListFields['filestatus'] = 'filestatus';
         }
     }
     if (count($relatedListFields) > 0) {
         $currentUser = Users_Record_Model::getCurrentUserModel();
         $queryGenerator = new QueryGenerator($relatedModuleName, $currentUser);
         $queryGenerator->setFields($relatedListFields);
         $selectColumnSql = $queryGenerator->getSelectClauseColumnSQL();
         $newQuery = spliti('FROM', $query);
         $selectColumnSql = 'SELECT DISTINCT vtiger_crmentity.crmid,' . $selectColumnSql;
         $query = $selectColumnSql . ' FROM ' . $newQuery[1];
     }
     $instance = CRMEntity::getInstance($relatedModuleName);
     $securityParameter = $instance->getUserAccessConditionsQuerySR($relatedModuleName, false, $recordId);
     if ($securityParameter != '') {
         $query .= $securityParameter;
     }
     return $query;
 }