Example #1
0
 public static function getInstance($value)
 {
     $db = PearDatabase::getInstance();
     if (Vtiger_Utils::isNumber($value)) {
         $sql = 'SELECT * FROM vtiger_org_share_action_mapping WHERE share_action_id = ?';
     } else {
         $sql = 'SELECT * FROM vtiger_org_share_action_mapping WHERE share_action_name = ?';
     }
     $params = array($value);
     $result = $db->pquery($sql, $params);
     if ($db->num_rows($result) > 0) {
         return self::getInstanceFromQResult($result);
     }
     return null;
 }
Example #2
0
 public static function getInstance($id)
 {
     $db = PearDatabase::getInstance();
     if (Vtiger_Utils::isNumber($id)) {
         $query = 'SELECT * FROM ' . Settings_Currency_Module_Model::tableName . ' WHERE id=?';
     } else {
         $query = 'SELECT * FROM ' . Settings_Currency_Module_Model::tableName . ' WHERE currency_name=?';
     }
     $params = array($id);
     $result = $db->pquery($query, $params);
     if ($db->num_rows($result) > 0) {
         $instance = new self();
         $row = $db->query_result_rowdata($result, 0);
         $instance->setData($row);
     }
     return $instance;
 }
 /**
  * Get instance of block
  * @param mixed block id or block label
  * @param Vtiger_Module Instance of the module if block label is passed
  */
 static function getInstance($value, $moduleInstance = false)
 {
     global $adb;
     $cache = Vtiger_Cache::getInstance();
     if ($moduleInstance && $cache->getBlockInstance($value, $moduleInstance->id)) {
         return $cache->getBlockInstance($value, $moduleInstance->id);
     } else {
         $instance = false;
         $query = false;
         $queryParams = false;
         if (Vtiger_Utils::isNumber($value)) {
             $query = "SELECT * FROM vtiger_blocks WHERE blockid=?";
             $queryParams = array($value);
         } else {
             $query = "SELECT * FROM vtiger_blocks WHERE blocklabel=? AND tabid=?";
             $queryParams = array($value, $moduleInstance->id);
         }
         $result = $adb->pquery($query, $queryParams);
         if ($adb->num_rows($result)) {
             $instance = new self();
             $instance->initialize($adb->fetch_array($result), $moduleInstance);
         }
         $cache->setBlockInstance($value, $instance->module->id, $instance);
         return $instance;
     }
 }
Example #4
0
 /**
  * Get instance by filterid or filtername
  * @param mixed filterid or filtername
  * @param Vtiger_Module Instance of the module to use when filtername is used
  */
 static function getInstance($value, $moduleInstance = false)
 {
     global $adb;
     $instance = false;
     $query = false;
     $queryParams = false;
     if (Vtiger_Utils::isNumber($value)) {
         $query = "SELECT * FROM vtiger_customview WHERE cvid=?";
         $queryParams = array($value);
     } else {
         $query = "SELECT * FROM vtiger_customview WHERE viewname=? AND entitytype=?";
         $queryParams = array($value, $moduleInstance->name);
     }
     $result = $adb->pquery($query, $queryParams);
     if ($adb->num_rows($result)) {
         $instance = new self();
         $instance->initialize($adb->fetch_array($result), $moduleInstance);
     }
     return $instance;
 }
Example #5
0
 /**
  * Static Function to get the instance of Vtiger Module Model for the given id or name
  * @param mixed id or name of the module
  */
 public static function getInstance($value)
 {
     $db = PearDatabase::getInstance();
     $instance = false;
     $query = false;
     if (Vtiger_Utils::isNumber($value)) {
         $query = 'SELECT * FROM vtiger_def_org_share INNER JOIN vtiger_tab ON vtiger_tab.tabid = vtiger_def_org_share.tabid WHERE vtiger_tab.tabid=?';
     } else {
         $query = 'SELECT * FROM vtiger_def_org_share INNER JOIN vtiger_tab ON vtiger_tab.tabid = vtiger_def_org_share.tabid WHERE name=?';
     }
     $result = $db->pquery($query, array($value));
     if ($db->num_rows($result)) {
         $row = $db->query_result_rowdata($result, 0);
         $instance = new Settings_SharingAccess_Module_Model();
         $instance->initialize($row);
         $instance->set('permission', $row['permission']);
         $instance->set('editstatus', $row['editstatus']);
     }
     return $instance;
 }
Example #6
0
 /**
  * Get instance of menu by label
  * @param String Menu label
  */
 static function getInstance($value)
 {
     global $adb;
     $query = false;
     $instance = false;
     if (Vtiger_Utils::isNumber($value)) {
         $query = "SELECT * FROM vtiger_parenttab WHERE parenttabid=?";
     } else {
         $query = "SELECT * FROM vtiger_parenttab WHERE parenttab_label=?";
     }
     $result = $adb->pquery($query, array($value));
     if ($adb->num_rows($result)) {
         $instance = new self();
         $instance->initialize($adb->fetch_array($result));
     }
     return $instance;
 }
Example #7
0
 public static function getInstanceWithIdOrName($value)
 {
     global $log;
     $log->debug("Entering Vtiger_Action_Model::getInstanceWithIdOnName(" . $value . ") method ...");
     $db = PearDatabase::getInstance();
     if (Vtiger_Utils::isNumber($value)) {
         $sql = 'SELECT * FROM vtiger_actionmapping WHERE actionid=? LIMIT 1';
     } else {
         $sql = 'SELECT * FROM vtiger_actionmapping WHERE actionname=?';
     }
     $params = array($value);
     $result = $db->pquery($sql, $params);
     if ($db->num_rows($result) > 0) {
         $log->debug("Exiting Vtiger_Action_Model::getInstanceWithIdOnName(" . $value . ") method ...");
         return self::getInstanceFromQResult($result);
     }
     $log->debug("Exiting Vtiger_Action_Model::getInstanceWithIdOnName(" . $value . ") method ...");
     return null;
 }