/** * Generates a form to define the reverse values of a specific property for a resource * This allows to set/remove multiple triples that share the same object * * @param core_kernel_classes_Resource $resource * @param core_kernel_classes_Property $property * @return tao_helpers_form_GenerisTreeForm */ public static function buildReverseTree(core_kernel_classes_Resource $resource, core_kernel_classes_Property $property) { $tree = new self($resource, $property); $domainCollection = $property->getDomain(); if (!$domainCollection->isEmpty()) { $domain = $domainCollection->get(0); $tree->setData('rootNode', $domain->getUri()); $tree->setData('dataUrl', _url('getData', 'GenerisTree', 'tao')); $tree->setData('saveUrl', _url('setReverseValues', 'GenerisTree', 'tao')); $values = array_keys($domain->searchInstances(array($property->getUri() => $resource), array('recursive' => true, 'like' => false))); $tree->setData('values', $values); $openNodeUris = tao_models_classes_GenerisTreeFactory::getNodesToOpen($values, $domain); $tree->setData('openNodes', $openNodeUris); } return $tree; }
public function findAllByOptionValue($value_id, $customer_id) { $tmp_cards = $this->getTable()->findAllByOptionValue($value_id, $customer_id); $cards = array(); $remove_cards = false; if (!empty($tmp_cards)) { foreach ($tmp_cards as $tmp_card) { $card = new self(); $card->setData($tmp_card->getData()); $is_locked = false; if (!is_null($card->getLastError())) { $now = $this->formatDate(null, 'y-MM-dd HH:mm:ss'); $date = new Zend_Date($card->getLastError()); $last_error = $date->addDay(1)->toString('y-MM-dd HH:mm:ss'); $is_locked = $last_error > $now && $card->getNumberOfError() >= 3; if (!$last_error > $now) { $card->setNumberOfError(0); } } $card->setIsLocked($is_locked)->setId($card->getCustomerCardId()); // Si la carte est bloquée, on ne conserve que celle là, on supprime les autres et on stop le traitement if ($is_locked) { $cards = array($card); break; } else { $cards[] = $card; } } } return $cards; }
/** * Function to get the instance of the Tracker Record Model from the list of key-value mapping * @param <Array> $valueMap * @return Vtiger_TrackRecord_Model instance */ public static function getInstance($valueMap) { $instance = new self(); $instance->setData($valueMap); $instance->setModule($valueMap['module_name']); return $instance; }
/** * Create a new pattern template from array. * * @param array $data * @return Raincolour\Containers\Template */ public static function make(array $data) { $template = new self(); $template->setData($data); $template->validate(); return $template; }
static function fromException($exception) { $exceptionClass = get_class($exception); $response = new self(); if ($exception instanceof \RpcException) { $response->setHttpStatus($exception->getHttpStatus()); $response->setCode($exception->getRpcErrorCode()); $response->setData(['data' => $exception->getData(), 'trace' => $exception->getTrace()]); } else { $response->setHttpStatus(500); $response->setCode('UNKOWN'); $response->setData(['trace' => $exception->getTrace()]); } $response->setMessage($exception->getMessage()); return $response; }
/** * Function to get the instance of the Tracker Record Model from the list of key-value mapping * @param <Array> $valueMap * @return Vtiger_TrackRecord_Model instance */ public static function getInstance($valueMap) { global $log; $log->debug("Entering ./models/TrackRecord.php::staticgetInstance"); $instance = new self(); $instance->setData($valueMap); $instance->setModule($valueMap['module_name']); return $instance; }
/** * Function to get the instance of CSS Script model from a given Vtiger_Link object * @param Vtiger_Link $linkObj * @return Vtiger_CssScript_Model instance */ public static function getInstanceFromLinkObject(Vtiger_Link $linkObj) { $objectProperties = get_object_vars($linkObj); $linkModel = new self(); foreach ($objectProperties as $properName => $propertyValue) { $linkModel->{$properName} = $propertyValue; } return $linkModel->setData($objectProperties); }
public static function factory(array $data) { $rpc = new self(); $rpc->setId($data['tid']); $rpc->setAction($data['action']); $rpc->setMethod($data['method']); $rpc->setData($data['data'] ?: array()); $rpc->setParameters($data); return $rpc; }
public static function getInstanceById($id) { $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT * FROM yetiforce_menu WHERE id = ?;', [$id]); if ($db->num_rows($result) == 0) return false; $instance = new self(); $instance->setData($db->raw_query_result_rowdata($result, 0)); return $instance; }
/** * Método mágico (atribui) * @param string $key * @param mixed $value * @return void */ public function __set($key, $value) { if (is_array($value)) { $config = new self(); $value = $config->setData($value); } if (null === $key) { $this->data[] = $value; } else { $this->data[$key] = $value; } }
public static function getInstanceByCreator(Users_Record_Model $user) { $db = PearDatabase::getInstance(); $query = 'SELECT * FROM ' . self::tableName . ' WHERE creatorid=?'; $result = $db->pquery($query, array($user->getId())); $instance = new self(); if ($db->num_rows($result) > 0) { $row = $db->query_result_rowdata($result, 0); $instance->setData($row); } return $instance; }
public static function getInstanceById($reportModel) { $self = new self(); $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT * FROM vtiger_reporttype WHERE reportid = ?', array($reportModel->getId())); $data = $db->query_result($result, 0, 'data'); if(!empty($data)) { $decodeData = Zend_Json::decode(decode_html($data)); $self->setData($decodeData); $self->setParent($reportModel); $self->setId($reportModel->getId()); } return $self; }
public static function getUserInstance($widgetId) { $currentUser = Users_Record_Model::getCurrentUserModel(); $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT vtiger_module_dashboard_widgets.* FROM vtiger_module_dashboard_widgets INNER JOIN vtiger_links ON vtiger_links.linkid = vtiger_module_dashboard_widgets.linkid WHERE linktype = ? AND vtiger_module_dashboard_widgets.id = ? AND vtiger_module_dashboard_widgets.userid = ?', array('DASHBOARDWIDGET', $widgetId, $currentUser->getId())); $self = new self(); if ($db->num_rows($result)) { $row = $db->query_result_rowdata($result, 0); $self->setData($row); } return $self; }
public static function create($filters = null, $data = null, $accountBookingFilters = null) { if (!$filters) { throw new Exception('No filters specified'); } if (!$data) { throw new Exception('No data specified'); } $obj = new self(); $obj->setFilters($filters); $obj->setData($data); $obj->setAccountBookingFilters($accountBookingFilters); return $obj; }
/** * Static method for loading a Config instance. * * @param string|array $path * * @return Config */ public static function load($path) { $self = new self([]); $paths = $self->getValidPath($path); $data = []; foreach ($paths as $path) { // Get file information $info = pathinfo($path); $extension = isset($info['extension']) ? $info['extension'] : ''; $parser = $self->getParser($extension); // Try and load file $data = array_replace_recursive($data, $parser->parse($path)); } $self->setData($data); return $self; }
/** * Function to get the instance of the CompanyDetails model for a given organization id * @param <Number> $id * @return Vtiger_CompanyDetails_Model instance */ public static function getInstanceById($id = 1) { $companyDetails = Vtiger_Cache::get('vtiger', 'organization'); if (!$companyDetails) { $db = PearDatabase::getInstance(); $sql = 'SELECT * FROM vtiger_organizationdetails WHERE organization_id=?'; $params = array($id); $result = $db->pquery($sql, $params); $companyDetails = new self(); if ($result && $db->num_rows($result) > 0) { $resultRow = $db->query_result_rowdata($result, 0); $companyDetails->setData($resultRow); } Vtiger_Cache::set('vtiger','organization',$companyDetails); } return $companyDetails; }
public static function getInstanceById($recordId, $qualifiedModuleName) { $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT * FROM ' . self::tableName . ' WHERE id = ?', array($recordId)); if ($db->num_rows($result)) { $moduleModel = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName); $rowData = $db->query_result_rowdata($result, 0); $recordModel = new self(); $recordModel->setData($rowData); $parameters = Zend_Json::decode(decode_html($recordModel->get('parameters'))); foreach ($parameters as $fieldName => $fieldValue) { $recordModel->set($fieldName, $fieldValue); } return $recordModel; } return false; }
/** * Function to get the history of updates on a record * @param <type> $record - Record model * @param <type> $limit - number of latest changes that need to retrieved * @return <array> - list of ModTracker_Record_Model */ public static function getUpdates($parentRecordId, $pagingModel) { $db = PearDatabase::getInstance(); $recordInstances = array(); $startIndex = $pagingModel->getStartIndex(); $pageLimit = $pagingModel->getPageLimit(); $listQuery = "SELECT * FROM vtiger_modtracker_basic WHERE crmid = ? " . " ORDER BY changedon DESC LIMIT {$startIndex}, {$pageLimit}"; $result = $db->pquery($listQuery, array($parentRecordId)); $rows = $db->num_rows($result); for ($i = 0; $i < $rows; $i++) { $row = $db->query_result_rowdata($result, $i); $recordInstance = new self(); $recordInstance->setData($row)->setParent($row['crmid'], $row['module']); $recordInstances[] = $recordInstance; } return $recordInstances; }
/** * Function returns the Scheduled Reports Model instance * @param <Number> $recordId * @return <Reports_ScehduleReports_Model> */ public static function getInstanceById($recordId) { $db = PearDatabase::getInstance(); $scheduledReportModel = new self(); if (!empty($recordId)) { $scheduledReportResult = $db->pquery('SELECT * FROM vtiger_schedulereports WHERE reportid = ?', array($recordId)); if ($db->num_rows($scheduledReportResult) > 0) { $reportScheduleInfo = $db->query_result_rowdata($scheduledReportResult, 0); $reportScheduleInfo['schdate'] = decode_html($reportScheduleInfo['schdate']); $reportScheduleInfo['schdayoftheweek'] = decode_html($reportScheduleInfo['schdayoftheweek']); $reportScheduleInfo['schdayofthemonth'] = decode_html($reportScheduleInfo['schdayofthemonth']); $reportScheduleInfo['schannualdates'] = decode_html($reportScheduleInfo['schannualdates']); $reportScheduleInfo['recipients'] = decode_html($reportScheduleInfo['recipients']); $reportScheduleInfo['specificemails'] = decode_html($reportScheduleInfo['specificemails']); $scheduledReportModel->setData($reportScheduleInfo); } } return $scheduledReportModel; }
/** * Factory - create the response * * @param $data * * @return self|boolean */ public function create($data) { $response = new self(); // Parse XML try { $response->setStatus($data['response']['status']); if (isset($data['response']['errormessage'])) { $response->setErrormessage($data['response']['errormessage']); } if (isset($data['response']['data'])) { $response->setData($data['response']['data']); } return $response; } catch (\Exception $e) { $response->setStatus(self::ERROR); $response->setErrorMessage($e->getMessage()); return false; } }
/** * Parse a parent object from a string * * @param string $stream * @return ParentObject */ public static function parse($stream) { $parent = new self(); $parent->setIndex(substr($stream, 0, strpos($stream, ' '))); $stream = str_replace($parent->getIndex() . ' 0 obj', '[{parent_index}] 0 obj', $stream); // Determine the kids count. $matches = []; preg_match('/\\/Count\\s\\d*/', $stream, $matches); $count = $matches[0]; $count = str_replace('/Count ', '', $count); $stream = str_replace('Count ' . $count, 'Count [{count}]', $stream); // Determine the kids object indices. $kids = trim(substr($stream, strpos($stream, '/Kids') + 5)); $kids = substr($kids, 0, 1) == '[' ? substr($kids, 0, strpos($kids, ']') + 1) : substr($kids, 0, strpos($kids, ' R') + 2); $kidIndices = $parent->getDictionaryReferences(substr($stream, strpos($stream, '/Kids') + 5)); $parent->setKids($kidIndices); $parent->setData(str_replace($kids, '[[{kids}]]', $stream) . "\n"); return $parent; }
/** * Parse a root object from a string * * @param string $stream * @return RootObject */ public static function parse($stream) { $root = new self(); // Else, parse out any metadata and determine the root and parent object indices. $root->setIndex(substr($stream, 0, strpos($stream, ' '))); $stream = str_replace($root->getIndex() . ' 0 obj', '[{root_index}] 0 obj', $stream); // Strip away any metadata if (strpos($stream, '/Metadata') !== false) { $metadata = substr($stream, strpos($stream, 'Metadata')); $metadata = '/' . substr($metadata, 0, strpos($metadata, '/')); $stream = str_replace($metadata, '', $stream); } // Determine the parent index. $parent = substr($stream, strpos($stream, '/Pages') + 6); $parent = trim(substr($parent, 0, strpos($parent, '0 R'))); $root->setParentIndex($parent); $stream = str_replace('Pages ' . $root->getParentIndex() . ' 0 R', 'Pages [{parent_index}] 0 R', $stream); // Set the root object parent index and the data. $root->setData($stream . "\n"); return $root; }
/** * Static Function to get the instance of the User Record model from the given Users object * @return Users_Record_Model instance */ public static function getInstanceFromUserObject($userObject) { $objectProperties = get_object_vars($userObject); $userModel = new self(); foreach ($objectProperties as $properName => $propertyValue) { $userModel->{$properName} = $propertyValue; } return $userModel->setData($userObject->column_fields)->setModule('Users')->setEntity($userObject); }
public static function getInstanceBySourceUUID($sourceuuid) { $db = PearDatabase::getInstance(); $record = new self(); $query = 'SELECT * FROM ' . self::moduletableName . ' WHERE sourceuuid=?'; $params = array($sourceuuid); $result = $db->pquery($query, $params); $rowCount = $db->num_rows($result); if ($rowCount) { $rowData = $db->query_result_rowdata($result, 0); $record->setData($rowData); } return $record; }
public static function getInstanceById($id, $type = self::PRODUCT_AND_SERVICE_TAX) { $db = PearDatabase::getInstance(); $tablename = 'vtiger_inventorytaxinfo'; if ($type == self::SHIPPING_AND_HANDLING_TAX) { $tablename = 'vtiger_shippingtaxinfo'; } $query = 'SELECT * FROM ' . $tablename . ' WHERE taxid=?'; $result = $db->pquery($query, array($id)); $taxRecordModel = new self(); if ($db->num_rows($result) > 0) { $row = $db->query_result_rowdata($result, 0); $taxRecordModel->setData($row)->setType($type); } return $taxRecordModel; }
/** * Function to get the instance of Roles record model from query result * @param <Object> $result * @param <Number> $rowNo * @return Settings_Roles_Record_Model instance */ public static function getInstanceFromQResult($result, $rowNo) { $db = PearDatabase::getInstance(); $row = $db->query_result_rowdata($result, $rowNo); $role = new self(); return $role->setData($row); }
public static function create($data) { $response = new self(); $response->setData($data); return $response; }
/** * Parse a page object from a string * * @param string $stream * @return PageObject */ public static function parse($stream) { $page = new self(); $page->setIndex(substr($stream, 0, strpos($stream, ' '))); // Determine the page parent object index. $parent = substr($stream, strpos($stream, '/Parent') + 7); $parent = trim(substr($parent, 0, strpos($parent, '0 R'))); $page->setParentIndex($parent); // Determine the page width and height. $dims = substr($stream, strpos($stream, '/MediaBox') + 9); $dims = substr($dims, 0, strpos($dims, ']')); $dims = trim(str_replace('[', '', $dims)); $dims = explode(' ', $dims); $page->setWidth($dims[2]); $page->setHeight($dims[3]); // Determine the page content objects. if (strpos($stream, '/Contents') !== false) { $contents = substr($stream, strpos($stream, '/Contents') + 9); $contents = $page->getDictionaryReferences($contents); foreach ($contents as $content) { $page->addContentIndex($content); } // Set placeholder $contents = substr($stream, strpos($stream, '/Contents') + 9); if (strpos($contents, '[') !== false) { $contents = substr($contents, 0, strpos($contents, ']') + 1); $stream = str_replace($contents, '[{content_objects}]', $stream); } else { $contents = strpos($contents, '/') !== false ? substr($contents, 0, strpos($contents, '/')) : substr($contents, 0, strpos($contents, '>')); $stream = str_replace($contents, '[{content_objects}]', $stream); } } // If they exist, determine the page annotation objects. if (strpos($stream, '/Annots') !== false) { $annots = substr($stream, strpos($stream, '/Annots') + 7); $annots = $page->getDictionaryReferences($annots); foreach ($annots as $annot) { $page->addAnnotIndex($annot); } // Set placeholder $annots = substr($stream, strpos($stream, '/Annots') + 7); if (strpos($annots, '[') !== false) { $annots = substr($annots, 0, strpos($annots, ']') + 1); $stream = str_replace($annots, '[{annotations}]', $stream); } else { $annots = strpos($annots, '/') !== false ? substr($annots, 0, strpos($annots, '/')) : substr($annots, 0, strpos($annots, '>')); $stream = str_replace($annots, '[{annotations}]', $stream); } } // If they exist, determine the page font references. if (strpos($stream, '/Font') !== false) { $fonts = substr($stream, strpos($stream, 'Font')); $fonts = substr($fonts, 0, strpos($fonts, '>>') + 2); $stream = str_replace('/' . $fonts, '[{fonts}]', $stream); $fonts = str_replace('Font<<', '', $fonts); $fonts = str_replace('>>', '', $fonts); $fonts = explode('/', $fonts); foreach ($fonts as $value) { if ($value != '') { $page->addFontReference('/' . $value); } } } // If they exist, determine the page XObjects references. if (strpos($stream, '/XObject') !== false) { $xo = substr($stream, strpos($stream, 'XObject')); $xo = substr($xo, 0, strpos($xo, '>>') + 2); $stream = str_replace('/' . $xo, '[{xobjects}]', $stream); $xo = str_replace('XObject<<', '', $xo); $xo = str_replace('>>', '', $xo); $xo = explode('/', $xo); foreach ($xo as $value) { if ($value != '') { $page->addXObjectReference('/' . $value); } } } // If they exist, determine the page graphic states. if (strpos($stream, '/ExtGState') !== false) { $gState = substr($stream, strpos($stream, 'ExtGState')); $gState = '/' . substr($gState, 0, strpos($gState, '>>') + 2); } else { $gState = ''; } // If any groups exist if (strpos($stream, '/Group') !== false) { $group = substr($stream, strpos($stream, 'Group')); $group = '/' . substr($group, 0, strpos($group, '>>') + 2); } else { $group = ''; } // If resources exists if (strpos($stream, '/Resources') !== false) { $resources = substr($stream, strpos($stream, 'Resources')); if (strpos($resources, ' R') !== false) { $resources = '/' . substr($resources, 0, strpos($resources, ' R') + 2); } else { if (strpos($resources, '>>') !== false) { $resources = '/' . substr($resources, 0, strpos($resources, '>>') + 2); } else { $resources = "/Resources<</ProcSet[/PDF/Text/ImageB/ImageC/ImageI][{xobjects}][{fonts}]{$gState}>>"; } } } else { $resources = "/Resources<</ProcSet[/PDF/Text/ImageB/ImageC/ImageI][{xobjects}][{fonts}]{$gState}>>"; } if (substr_count($resources, '<<') > substr_count($resources, '>>')) { $resources .= str_repeat('>>', substr_count($resources, '<<') - substr_count($resources, '>>')); } $page->setData("\n[{page_index}] 0 obj\n<</Type/Page/Parent [{parent}] 0 R[{annotations}]/MediaBox" . "[0 0 [{width}] [{height}]]{$group}[{content_objects}]{$resources}>>\nendobj\n"); return $page; }
/** * Get the SmKialaCountry where the shipment is picked up * * @return boolean|SmKialaCountry */ public static function getPickupCountry() { $result = Db::getInstance()->getRow(' SELECT `id_sm_kiala_country`, `id_country`, `dspid`, `sender_id`, `password`, `preparation_delay`, `active` FROM `' . _DB_PREFIX_ . 'sm_kiala_country` WHERE `pickup_country` = 1'); if (!$result) { return false; } $kiala_country = new self(); $kiala_country->setData($result); return $kiala_country; }
/** * Function to get the instance of Custom View module, given custom view id * @param <Integer> $cvId * @return CustomView_Record_Model instance, if exists. Null otherwise */ public static function getInstanceById($cvId) { $db = PearDatabase::getInstance(); $sql = 'SELECT * FROM vtiger_customview WHERE cvid = ?'; $params = array($cvId); $result = $db->pquery($sql, $params); if ($db->num_rows($result) > 0) { $row = $db->query_result_rowdata($result, 0); $customView = new self(); return $customView->setData($row)->setModule($row['entitytype']); } return null; }