Example #1
0
 public function isHideBlock($record, $view)
 {
     $db = PearDatabase::getInstance();
     $result = $db->pquery("SELECT * FROM vtiger_blocks_hide WHERE enabled = ? AND blockid = ? AND view LIKE '%{$view}%';", array(1, $this->get('id')));
     $num_rows = $db->num_rows($result);
     $hideBlocks = array();
     for ($i = 0; $i < $num_rows; $i++) {
         $row = $db->raw_query_result_rowdata($result, $i);
         $hideBlocks[] = $row;
     }
     if (count($hideBlocks) == 0) {
         return true;
     }
     require_once "modules/com_vtiger_workflow/VTJsonCondition.inc";
     require_once "modules/com_vtiger_workflow/VTEntityCache.inc";
     require_once "modules/com_vtiger_workflow/VTWorkflowUtils.php";
     $conditionStrategy = new VTJsonCondition();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $util = new VTWorkflowUtils();
     $entityCache = new VTEntityCache($currentUser);
     $wsId = vtws_getWebserviceEntityId($record->getModuleName(), $record->getId());
     $showBlock = false;
     foreach ($hideBlocks as $hideBlock) {
         $expr = Zend_Json::decode($hideBlock['conditions']);
         if (!$record->getId() && $expr) {
             continue;
         }
         $showBlock = $conditionStrategy->evaluate($hideBlock['conditions'], $entityCache, $wsId);
     }
     return !$showBlock;
 }
Example #2
0
 public function checkFiltersForRecord($recordId)
 {
     $test = Vtiger_Cache::get('PdfCheckFiltersForRecord' . $this->getId(), $recordId);
     if ($test !== false) {
         return $test;
     }
     vimport("~/modules/com_vtiger_workflow/VTJsonCondition.inc");
     vimport("~/modules/com_vtiger_workflow/VTEntityCache.inc");
     vimport("~/include/Webservices/Retrieve.php");
     $conditionStrategy = new VTJsonCondition();
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $entityCache = new VTEntityCache($currentUser);
     $wsId = vtws_getWebserviceEntityId($this->get('module_name'), $recordId);
     $test = $conditionStrategy->evaluate($this->getRaw('conditions'), $entityCache, $wsId);
     Vtiger_Cache::set('PdfCheckFiltersForRecord' . $this->getId(), $recordId, $test);
     return $test;
 }