/** * Get user by id * * @param integer $userId User id * * @return User */ public static function getById($userId = null) { if ($userId) { $user = new self(); if ($user->get()->where('id', '=', $userId)->count() > 0) { return $user->get()->where('id', '=', $userId)->current(); } } return null; }
static function active() { $Model = new self(); $Model->active = true; $Model->related('image'); return $Model->get(); }
/** * Check that the current user has the requested capability. * * @param array $all_capabilities The full list of capabilities granted (to add to). * @param array $caps The capabilities being checked. * @param array $args Values being passed in by `current_user_can()`. * * @return array */ public static function check($all_capabilities, $caps, $args) { // See if it's one of our capabilities being checked. $cap_full_name = array_shift($caps); if (stripos($cap_full_name, TABULATE_SLUG) === false) { return $all_capabilities; } // Strip the leading 'tabulate_' from the capability name. $cap = substr($cap_full_name, strlen(TABULATE_SLUG) + 1); // Set up basic data. $table_name = $args[2] ? $args[2] : false; $grants = new self(); // Users with 'promote_users' capability can do everything. if (isset($all_capabilities['promote_users'])) { $all_capabilities[$cap_full_name] = true; } // Table has no grants, or doesn't have this one. $table_grants = $grants->get($table_name); if (!$table_grants || !isset($table_grants[$cap])) { return $all_capabilities; } // Table has grants of this capability; check whether the user has one // of the roles with this capability. $user = wp_get_current_user(); $intersect = array_intersect($table_grants[$cap], $user->roles); if (count($intersect) > 0) { $all_capabilities[$cap_full_name] = true; } return $all_capabilities; }
public function get() { $parsedMessage = array(); $message = $this->splitMessage($this->message); $message["header"] = $this->parseHeader($message["header"]); $message["contentType"] = $this->parseContentType($message["header"]["content-type"], $message["header"]["content-transfer-encoding"], $message["header"]["content-disposition"], $message["header"]["content-description"]); $message["charset"] = $this->getCharset($message["header"]["content-type"]); $partId = md5(uniqid("", true)); $parsedMessage[$partId] = array("parentPartId" => $this->parentPartId, "header" => $message["header"], "contentType" => $message["contentType"], "charset" => $message["charset"]); if ($this->isCompositeMessage($message["contentType"])) { $parsedMessage[$partId]["body"] = false; if ($this->isMultipartMessage($message["contentType"]["type"])) { $message["bodyParts"] = $this->splitBodyParts($message["body"], $message["contentType"]["boundary"]); } else { $message["bodyParts"][] = $message["body"]; } foreach ($message["bodyParts"] as $bodyPart) { $childParts = new self($bodyPart, $partId); $parsedMessage = array_merge($parsedMessage, $childParts->get()); } } else { $parsedMessage[$partId]["body"] = $this->decodeBody($message["body"], $message["contentType"]); } return $parsedMessage; }
/** * @param $key * @param null $default * @return mixed * @throws \Exception */ public static function fast($key, $default = null) { $keyPath = explode('.', $key, 2); if (count($keyPath) != 2) { throw new \Exception('incorrect setting $key'); } $config = new self($keyPath[0]); return $config->get($keyPath[1], $default); }
static function deleteAll($parentId) { $l10n = new self($parentId); $materialPath = Registry::getInstance()->get('material_path'); foreach (array_keys($l10n->getLocales()) as $localeId) { @unlink($materialPath . $l10n->get('fileName', $localeId)); } parent::deleteAll($parentId); }
/** * All options to array * * @return array */ public static function allToOptionsArray() { $object = new self(); $conditions = $object->get(); $optionsArray = array(); foreach ($conditions as $condition) { $optionsArray[$condition->option] = $condition->value; } return $optionsArray; }
public static function getList() { $list = new self(); $list->sortBy('formName'); $formTypes = $list->get(0); $result = []; foreach ($formTypes as $formType) { $result[$formType->getID()] = $formType->getFormName(); } return $result; }
/** * Get user by id * * @param integer $userId User id * * @return User */ public static function getById($userId = null) { if ($userId) { $user = new self(); $criteria = $user->createCriteria('id', '=', $userId); $result = $user->get(array($criteria)); if (!empty($result)) { return $result[0]; } } return null; }
public static function getById($id) { $key = 'f' . $id; if ($c = Cache::get($key)) { return $c; } $ret = new self(); $ret->id = $id; $ret->path = self::path($id); $ret->get(); Cache::set($key, $ret); return $ret; }
/** * {@inheritDoc} */ public function groupBy(callable $groupKeyFunction) { $groupedMap = new self(); foreach ($this->keyIdentityPositionMap as $identityHash => $position) { $keyCopy = $key = $this->keys[$position]; $valueCopy = $value =& $this->values[$position]; $groupKey = $groupKeyFunction($valueCopy, $keyCopy); if ($groupedMap->contains($groupKey)) { $groupMap = $groupedMap->get($groupKey); } else { $groupMap = new self(); $groupedMap->set($groupKey, $groupMap); } $groupMap->setInternal($key, $value, $identityHash, true); } return $groupedMap; }
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; }
public static function retrieve($endpoint, $params = null, $method = 'get') { $fs = new self(); $method = strtolower($method); switch ($method) { case 'get': return $fs->get($endpoint, $params); break; case 'post': return $fs->post($endpoint, $params); break; case 'delete': return $fs->delete($endpoint, $params); break; default: throw new ddFoursquareBadRequestException('The given method is invalid.'); } }
private function get_value($v) { if ($v instanceof self) { $v = $v->get(); } else { if (is_bool($v)) { $v = $v ? 'true' : 'false'; } else { if ($v === '') { $v = null; } else { if (is_array($v) || is_object($v)) { $r = ''; foreach ($v as $k => $c) { if (is_numeric($k) && is_object($c)) { $e = explode('\\', get_class($c)); $k = array_pop($e); } if (is_numeric($k)) { $k = 'data'; } $x = new self($k, $c); $x->escape($this->esc); $r .= $x->get(); } $v = $r; } else { if ($this->esc && strpos($v, '<![CDATA[') === false && preg_match("/&|<|>|\\&[^#\\da-zA-Z]/", $v)) { $v = '<![CDATA[' . $v . ']]>'; } } } } } return $v; }
/** * Function to get record instance by using id and moduleName * @param <Integer> $recordId * @param <String> $qualifiedModuleName * @return <Rss_Record_Model> RecordModel */ public static function getInstanceById($recordId, $qualifiedModuleName) { $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT * FROM vtiger_rss WHERE rssid = ?', array($recordId)); if ($db->num_rows($result)) { $rowData = $db->query_result_rowdata($result, 0); $recordModel = new self(); $recordModel->setData($rowData); $recordModel->setModule($qualifiedModuleName); $rss = fetch_rss($recordModel->get('rssurl')); $rss->items = $recordModel->setSenderInfo($rss->items); $recordModel->setRssValues($rss); $recordModel->setRssObject($rss); return $recordModel; } return false; }
/** * Renvoie l'url rewritée complète. * Si l'id de la route à utiliser pour la base de l'url a déjà été défini par les méthodes * \Aouka\Project\Routing\UrlRewriter::setDefaultUrl() ou \Aouka\Project\Routing\UrlRewriter::setUrlId(), * c'est ce dernier id qui sera utilisé. * * @param string $sRouteId Id de la route à utiliser pour rewriter l'url. Surcharge le précédent Id éventuel. * @param array $aParams Liste des paramètres associés à la route. * @return Url */ public static function getUrl($sRouteId = '', $aParams = []) { $oSelf = new self(); $cUriComponent = null; $aUriComponentsToRewrite = []; if ($sRouteId) { $oSelf->setRoute($sRouteId, $aParams); $cUriComponent = $oSelf->getComponentType($sRouteId); switch ($cUriComponent) { case self::URI_PATH: $aUriComponentsToRewrite = [self::URI_BASEPATH, self::URI_PATH]; break; case self::URI_COMPLETE_PATH: $aUriComponentsToRewrite = [self::URI_COMPLETE_PATH]; break; } } $oSelf->rewrite($aUriComponentsToRewrite); return $oSelf->get($cUriComponent); }
/** * @param bool $updateNulls * @return bool */ public function store( $updateNulls = false ) { global $_CB_framework, $_PLUGINS; $new = ( $this->get( 'id' ) ? false : true ); $old = new self(); $this->set( 'date', $this->get( 'date', Application::Database()->getUtcDateTime() ) ); if ( isset( $_FILES['file']['tmp_name'] ) && ( ! empty( $_FILES['file']['tmp_name'] ) ) ) { $basePath = $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/cbgroupjivefile'; $filePath = $basePath . '/' . (int) $this->group()->get( 'category' ) . '/' . (int) $this->group()->get( 'id' ); CBGroupJive::createDirectory( $basePath, $this->group()->get( 'category' ), $this->group()->get( 'id' ) ); $fileExtension = strtolower( preg_replace( '/[^-a-zA-Z0-9_]/', '', pathinfo( $_FILES['file']['name'], PATHINFO_EXTENSION ) ) ); $fileName = Get::clean( pathinfo( $_FILES['file']['name'], PATHINFO_FILENAME ), GetterInterface::STRING ) . '.' . $fileExtension; $fileId = uniqid(); $newFileName = $fileId . '.' . $fileExtension; if ( ! move_uploaded_file( $_FILES['file']['tmp_name'], $filePath . '/' . $newFileName ) ) { $this->setError( CBTxt::T( 'GROUP_FILE_UPLOAD_FAILED', 'The file [file] failed to upload!', array( '[file]' => $newFileName ) ) ); return false; } else { @chmod( $filePath . '/' . $newFileName, 0755 ); } if ( $this->get( 'file' ) && file_exists( $filePath . '/' . $this->get( 'file' ) ) ) { @unlink( $filePath . '/' . $this->get( 'file' ) ); } $this->set( 'file', $newFileName ); $this->set( 'filename', $fileName ); $params = $this->params(); $params->unsetEntry( 'name' ); $params->unsetEntry( 'extension' ); $params->unsetEntry( 'mimetype' ); $params->unsetEntry( 'filesize' ); $params->set( 'name', $this->name() ); $params->set( 'extension', $this->extension() ); $params->set( 'mimetype', $this->mimeType() ); $params->set( 'filesize', $this->size( true ) ); $this->set( 'params', $params->asJson() ); } elseif ( ! $this->get( 'filename' ) ) { $this->set( 'filename', $this->get( 'file' ) ); } if ( ! $new ) { $old->load( (int) $this->get( 'id' ) ); $_PLUGINS->trigger( 'gj_onBeforeUpdateFile', array( &$this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onBeforeCreateFile', array( &$this ) ); } if ( ! parent::store( $updateNulls ) ) { return false; } if ( $old->get( 'id' ) && $this->get( 'file' ) && ( $old->get( 'group' ) != $this->get( 'group' ) ) ) { $basePath = $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/cbgroupjivefile'; $oldPath = $basePath . '/' . (int) $old->group()->get( 'category' ) . '/' . (int) $old->group()->get( 'id' ); $newPath = $basePath . '/' . (int) $this->group()->get( 'category' ) . '/' . (int) $this->group()->get( 'id' ); if ( is_dir( $oldPath ) ) { CBGroupJive::createDirectory( $basePath, $this->group()->get( 'category' ), $this->group()->get( 'id' ) ); if ( file_exists( $oldPath . '/' . $this->get( 'file' ) ) ) { @rename( $oldPath . '/' . $this->get( 'file' ), $newPath . '/' . $this->get( 'file' ) ); } } } if ( ! $new ) { $_PLUGINS->trigger( 'gj_onAfterUpdateFile', array( $this, $old ) ); } else { $_PLUGINS->trigger( 'gj_onAfterCreateFile', array( $this ) ); } return true; }
/** * Function to get the instance of Company details module model * @return <Settings_Vtiger_CompanyDetais_Model> $moduleModel */ public static function getInstance() { $moduleModel = new self(); $db = PearDatabase::getInstance(); $result = $db->pquery("SELECT * FROM vtiger_organizationdetails", array()); if ($db->num_rows($result) == 1) { $moduleModel->setData($db->query_result_rowdata($result)); $moduleModel->set('id', $moduleModel->get('organization_id')); } $moduleModel->getFields(); return $moduleModel; }
/** * Returns a reference to the global User object, only creating it if it doesn't already exist. * * @param mixed $id The user to load - Can be an integer or string * @return mixed Returns object if valid record found, false if not */ public static function getInstance($id = null) { static $instances; static $usernames; if (!isset($instances)) { $instances = array(); } if (!isset($usernames)) { $usernames = array(); } // Is this a username? if (!is_numeric($id)) { // Normalize and check if we have data for this username $id = strtolower(trim($id)); if (!isset($usernames[$id])) { $user = new self($id); // Save $usernames[$id] = $user->get('uidNumber'); $instances[$usernames[$id]] = $user; } // Change the $id from username to numeric ID $id = $usernames[$id]; } // Check for existing record if (empty($instances[$id]) || $instances[$id]->get('uidNumber') != $id) { $user = new self($id); $instances[$id] = $user; } // Ensure record has data if (!$instances[$id]->get('uidNumber')) { return false; } return $instances[$id]; }
/** * Get content from session, database, $_POST/$_GET superglobals or file * * @access public * @param mixed $params The name of the variable to retrieve, or an array of key => value pairs * @param string $type The type of variable * @param string $scope The scope of the variable * @return string */ public function get($params = '', $type = 'variable', $scope = 'user') { /* Sample use --------------------------------------------------------- {exp:stash:get name="title"} OR static call within PHP enabled templates or other add-on: <?php echo stash::get('title') ?> --------------------------------------------------------- */ // is this method being called statically from PHP? if (func_num_args() > 0 && !(isset($this) && get_class($this) == __CLASS__)) { // make sure we have a clean array in case the class has already been instatiated $this->EE->TMPL->tagparams = array(); if (is_array($params)) { $this->EE->TMPL->tagparams = $params; } else { $this->EE->TMPL->tagparams['name'] = $params; $this->EE->TMPL->tagparams['type'] = $type; $this->EE->TMPL->tagparams['scope'] = $scope; } // as this function is called statically, // we need to get an instance of this object and run get() $self = new self(); return $self->get(); } $name = strtolower($this->EE->TMPL->fetch_param('name')); $default = $this->EE->TMPL->fetch_param('default', ''); // default value $dynamic = (bool) preg_match('/1|on|yes|y/i', $this->EE->TMPL->fetch_param('dynamic')); $scope = strtolower($this->EE->TMPL->fetch_param('scope', 'user')); // user|site $bundle = $this->EE->TMPL->fetch_param('bundle', NULL); // save in a bundle? $match = $this->EE->TMPL->fetch_param('match', NULL); // regular expression to test value against $filter = $this->EE->TMPL->fetch_param('filter', NULL); // regex pattern to search for // do we want this tag to return the value, or just set the variable quietly in the background? $output = (bool) preg_match('/1|on|yes|y/i', $this->EE->TMPL->fetch_param('output', 'yes')); // parse any vars in the $name parameter? if ($this->parse_vars) { $name = $this->_parse_template_vars($name); } // low search support - do we have a query string? $low_query = $this->EE->TMPL->fetch_param('low_query', NULL); // context handling $context = $this->EE->TMPL->fetch_param('context', NULL); $global_name = $name; if ($context !== NULL && count(explode(':', $name) == 1)) { $name = $context . ':' . $name; $this->EE->TMPL->tagparams['context'] = NULL; } // read from file? $file = (bool) preg_match('/1|on|yes|y/i', $this->EE->TMPL->fetch_param('file')); $file_name = $this->EE->TMPL->fetch_param('file_name', FALSE); // default value if (!!$file_name) { $file = TRUE; } else { $file_name = $name; } // the variable value $value = NULL; // do we want to set the variable? $set = FALSE; // is it a segment? We need to support these in stash template files if (strncmp($name, 'segment_', 8) == 0) { $seg_index = substr($name, 8); $value = $this->EE->uri->segment($seg_index); } elseif (array_key_exists($name, $this->_stash)) { $value = $this->_stash[$name]; } else { // has it been bundled? if (!is_null($bundle)) { if (isset(self::$bundles[$bundle][$name])) { $value = $this->_stash[$name] = self::$bundles[$bundle][$name]; } //$set = TRUE; } elseif (!$this->_update) { // let's look in the database table cache, if we're not appending/prepending // narrow the scope to user? $session_id = $scope === 'user' ? $this->_session_id : ''; // replace '@' placeholders with the current context $stash_key = $this->_parse_context($name); // look for our key if ($parameters = $this->EE->stash_model->get_key($stash_key, $this->bundle_id, $session_id, $this->site_id)) { // save to session $value = $this->_stash[$name] = $parameters; } } // Are we looking for a superglobal or uri segment? if ($dynamic && $value == NULL || $dynamic && $this->replace) { $from_global = FALSE; // low search support if ($low_query !== NULL) { // has the query string been supplied or is it in POST? if (strncmp($low_query, 'stash:', 6) == 0) { $low_query = substr($low_query, 6); $low_query = $this->_stash[$low_query]; } $low_query = @unserialize(base64_decode(str_replace('_', '/', $low_query))); if (isset($low_query[$global_name])) { $from_global = $low_query[$global_name]; unset($low_query); } else { // set to empty value $from_global = ''; } } // or is it in the $_POST or $_GET superglobals ( run through xss_clean() )? if ($from_global === FALSE) { $from_global = $this->EE->input->get_post($global_name, TRUE); } if ($from_global === FALSE) { // no, so let's check the uri segments $segs = $this->EE->uri->segment_array(); foreach ($segs as $index => $segment) { if ($segment == $global_name && array_key_exists($index + 1, $segs)) { $from_global = $segs[$index + 1]; break; } } } if ($from_global !== FALSE) { // save to stash, and optionally to database, if save="yes" $value = $from_global; $set = TRUE; } } // Are we reading a file? if ($file && $value == NULL || $file && $this->replace) { $this->EE->TMPL->log_item("Stash: reading from file"); // construct a filepath. Here contexts become folders... $this->EE->load->helper('url_helper'); // make sure we have a url encoded path $file_path = explode(':', $file_name); foreach ($file_path as &$part) { $part = url_title($part); } $file_path = $this->path . implode('/', $file_path) . '.html'; if (file_exists($file_path)) { $value = file_get_contents($file_path); $set = TRUE; } else { $this->EE->output->show_user_error('general', sprintf($this->EE->lang->line('stash_file_not_found'), $file_path)); return; } } // set default if we still don't have a value if ($value == NULL) { $value = $default; $set = TRUE; } // create/update value of variable if required // note: don't save if we're updating a variable (to avoid recursion) if ($set && !$this->_update) { $this->EE->TMPL->tagparams['name'] = $name; $this->EE->TMPL->tagparams['output'] = 'yes'; $this->EE->TMPL->tagdata = $value; $this->replace = TRUE; $value = $this->set(); } } // set to default value if it is exactly '' (this permits '0' to be a valid Stash value) if ($value === '' && $default !== '') { $value = $default; } $this->EE->TMPL->log_item('Stash: RETRIEVED ' . $name . ' with value ' . $value); // save to bundle if ($bundle !== NULL) { if (!isset(self::$bundles[$bundle])) { self::$bundles[$bundle] = array(); } self::$bundles[$bundle][$name] = $value; } // output if ($output) { $value = $this->_parse_output($value, $match, $filter, $default); // if we're reading from a file (or a cached file) we need to parse early global vars // and remove any leftover {stash:} vars if ($file) { $value = $this->_parse_template_vars($value); // cleanup of leftover/undeclared stash: single and pairs if (strpos($value, LD . 'stash:') !== FALSE) { $value = preg_replace('#\\{/?stash:([^!]+?)\\}#', '', $value); } } return $value; } }
public function verifyPassword($mail, $password, $storelogin = 0) { $RS = database::Query('SELECT id, salt, password, status FROM users WHERE mail=:var1', array('var1' => $mail), $stats); if ($stats == 0) { return Texter::get('user')['accNotFound']; exit; } $user = new self($RS[0]['id']); if ($user->get('status') === 1) { if ($user->encryptPassword($password, $user->get('salt')) == $user->get('password')) { $user->doLogin($storelogin); return true; } else { return Texter::get('user|accNotFound'); } } else { return Texter::get('user|accNotActivated'); } }
static function item($Item) { $Model = new self(); return $Model->get($Item); }
/** * Provided as a convinience method for fetching a value within an existing * array without instantiating a SugarArray * * NOTE: This should only used where refactoring an array into a SugarArray * is unfeasible. This operation is more expensive than a direct * SugarArray as each time it creates and throws away a new instance * * @param array $haystack haystack * @param string $needle needle * @param mixed $default default value to return * @return mixed */ public static function staticGet($haystack, $needle, $default = null) { if (empty($haystack)) { return $default; } $array = new self($haystack); return $array->get($needle, $default); }
/** * Function to get instance by using XML node * @param <XML DOM> $extensionXMLNode * @return <Settings_ExtensionStore_Extension_Model> $extensionModel */ public function getInstanceFromArray($listing) { $extensionModel = new self(); foreach ($listing as $key => $value) { switch ($key) { case 'name' : $key = 'label'; break; case 'identifier': $key = 'name'; break; case 'version' : $key = 'pkgVersion'; break; case 'minrange': $key = 'vtigerVersion'; break; case 'maxrange': $key = 'vtigerMaxVersion'; break; case 'CustomerId': $key = 'publisher'; break; case 'price': $value = $value ? $value : 'Free'; break; case 'approvedon': $key = 'pubDate'; break; case 'ListingFileId': if ($value) { $key = 'downloadURL'; $value = $this->getExtensionsLookUpUrl() . '/customer/listingfiles?id='.$value; } break; case 'thumbnail': if ($value) { $key = 'thumbnailURL'; $value = str_replace('api', "_listingimages/$value", $this->getExtensionsLookUpUrl()); } break; case 'banner' : if ($value) { $key = 'bannerURL'; $value = str_replace('api', "_listingimages/$value", $this->getExtensionsLookUpUrl()); } break; case 'description': if($value){ $markDownInstance = new Michelf\Markdown(); $value = $markDownInstance->transform($value); } } $extensionModel->set($key, $value); } $label = $extensionModel->get('label'); if (!$label) { $extensionModel->set('label', $extensionModel->getName()); } $moduleModel = self::getModuleFromExtnName($extensionModel->getName()); if($moduleModel && $moduleModel->get('extnType') == 'language') { $trial = $extensionModel->get('trial'); $moduleModel->set('trial',$trial); } $extensionModel->set('moduleModel', $moduleModel); return $extensionModel; }
public static function __callStatic($method, $args) { $db = new self(); if (substr($method, 0, 3) == 'get' && strlen($method) > 3) { $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, 3))); $var = Inflector::lower($uncamelizeMethod); if (count($args) == 1) { $default = Arrays::first($args); } else { $default = null; } return $db->get($var, $default); } elseif (substr($method, 0, 3) == 'set' && strlen($method) > 3) { if (count($args) == 2) { $ttl = Arrays::last($args); } else { $ttl = 0; } $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($method, 3))); $var = Inflector::lower($uncamelizeMethod); return $db->set($var, Arrays::first($args), $ttl); } else { throw new \BadMethodCallException(__CLASS__ . ' => ' . $func); } }
/** * Load by section id * * @param integer $id Section id * @return void */ public static function loadBySectionId($id) { $model = new stdClass(); $model->_db = \App::get('db'); $model = new self(); $model->_tbl = new $model->_tbl_name($model->_db); $model->_tbl->load(array('section_id' => $id)); // Get criteria text $criteria = new Tables\SectionBadgeCriteria($model->_db); $criteria->load($model->get('criteria_id')); if ($criteria->get('text')) { $model->set('criteria_text', $criteria->get('text')); } return $model; }
/** * [search description] * * @method search * * @param [type] $val [description] * @param boolean $exact [description] * * @return [type] [description] */ public function search($val, $exact = false) { $dbIndices = new self('indices', $this->table); $rows = $dbIndices->get(); $ids = []; foreach ($rows as $row) { foreach ($row as $k => $v) { if (!$exact) { if (fnmatch("*{$val}*", $v)) { $ids[] = $row['object_id']; break; } } else { if ($val == $v) { $ids[] = $row['object_id']; break; } } } } return !empty($ids) ? $this->where(['id', 'IN', implode(',', $ids)]) : $this; }
/** * Function to get instance by using XML node * @param <XML DOM> $extensionXMLNode * @return <Settings_ModuleManager_Extension_Model> $extensionModel */ public static function getInstanceFromXMLNodeObject($extensionXMLNode) { $extensionModel = new self(); $objectProperties = get_object_vars($extensionXMLNode); foreach ($objectProperties as $propertyName => $propertyValue) { $propertyValue = (string) $propertyValue; if ($propertyName === 'description') { $propertyValue = nl2br(str_replace(array('<', '>'), array('<', '>'), br2nl(trim($propertyValue)))); } $extensionModel->set($propertyName, $propertyValue); } $label = $extensionModel->get('label'); if (!$label) { $extensionModel->set('label', $extensionModel->getName()); } return $extensionModel; }
public static function getInstance($company = 'Default') { $moduleModel = new self(); $db = PearDatabase::getInstance(); $result = $db->pquery("SELECT DISTINCT * FROM vtiger_organizationdetails where company=?", array($company)); if ($db->num_rows($result) == 1) { $moduleModel->setData($db->query_result_rowdata($result)); $moduleModel->set('id', $moduleModel->get('organization_id')); } return $moduleModel; }
protected static function moveStatic($name1, $name2) { $self = new self(); if ($self->exists($name)) { $content = $self->get($name1); $self->put($name2, $content); $self->delete($name1); } else { throw new \InvalidArgumentException("There is no file calls {$name}"); } }