public static function fromNative(\DateInterval $native) { $interval = new self(); $interval->native = $native; $interval->initialize(); return $interval; }
/** * Factory function */ public static function newFromTitle($title) { $evt = new self(); $evt->mOriginTitle = $title; $evt->initialize(); return $evt; }
public static function newItem($trackerId) { $obj = new self(); $obj->info = array(); $obj->definition = Tracker_Definition::get($trackerId); $obj->initialize(); return $obj; }
/** * @param string $path_ * @param string $storage_ * @param string[] $schema_ * * @return \Components\Media_Store */ public static function create($path_, $storage_, array $schema_) { $instance = new self($path_); $instance->initialize(); @file_put_contents($instance->path . '/' . self::NAME_MANIFEST, json_encode(['storage' => $storage_, 'schema' => $schema_])); $instance->load(); Cache::set('components/media/store/' . md5($path_), serialize($instance)); return $instance; }
/** * Function to get the instance of Vtiger Link Model from the given array of key-value mapping * @param <Array> $valueMap * @return Vtiger_Link_Model instance */ public static function getInstanceFromValues($valueMap) { $linkModel = new self(); $linkModel->initialize($valueMap); // To set other properties for Link Model foreach ($valueMap as $property => $value) { if (!isset($linkModel->{$property})) { $linkModel->{$property} = $value; } } return $linkModel; }
/** * Create a new instance * * @param ApplicationUserId $id * @param string $name * @param string $language * * @return SourcedUser */ public static function createUser(ApplicationUserId $id, $name, $language) { $user = new self(); $user->initialize($id, $name, $language); return $user; }
static function listAll($module=false, $asc=true) { global $adb; $instances = Array(); $result = false; if ($module) { if ($asc) $result = $adb->pquery('SELECT * FROM vtiger_modtracker_basic WHERE module=? ORDER BY id', Array($module)); else $result = $adb->pquery('SELECT * FROM vtiger_modtracker_basic WHERE module=? ORDER BY id DESC', Array($module)); } if ($result && $adb->num_rows($result)) { for ($index = 0; $index < $adb->num_rows($result); ++$index) { $rowmap = $adb->fetch_array($result); $instance = new self(); $instance->initialize($rowmap); $instances[] = $instance; } } return $instances; }
/** * Singleton to ensure that Content Types is only loaded once. * * @since 1.0.0 * @access public * @static * * @see wpct() * * @return WPCT|WP_Error The Content Types instance or an error object if it failed to initialize. */ public static function instance() { static $instance = null; if (null === $instance) { $status = self::check_requirements(); if (is_wp_error($status)) { $instance = $status; add_action('admin_notices', array(__CLASS__, 'admin_error_notice')); } else { $main_file = __FILE__; list($is_mu_plugin, $basedir_relative) = self::detect_library_mode($main_file); $instance = new self($main_file, $is_mu_plugin, $basedir_relative); $action = $is_mu_plugin ? 'muplugins_loaded' : 'plugins_loaded'; if (did_action($action)) { $instance->initialize(); } else { add_action($action, array($instance, 'initialize')); } } } return $instance; }
/** * Get all block instances associated with the module * @param Vtiger_Module Instance of the module */ static function getAllForModule($moduleInstance) { global $adb; $instances = false; $query = "SELECT * FROM vtiger_blocks WHERE tabid=? ORDER BY sequence"; $queryParams = array($moduleInstance->id); $result = $adb->pquery($query, $queryParams); for ($index = 0; $index < $adb->num_rows($result); ++$index) { $instance = new self(); $instance->initialize($adb->fetch_array($result), $moduleInstance); $instances[] = $instance; } return $instances; }
public static function getInstanceFromFieldId($fieldId, $moduleTabId) { $db = PearDatabase::getInstance(); if (is_string($fieldId)) { $fieldId = array($fieldId); } $query = 'SELECT * FROM vtiger_field WHERE fieldid IN (' . generateQuestionMarks($fieldId) . ') AND tabid=?'; $result = $db->pquery($query, array($fieldId, $moduleTabId)); $fieldModelList = array(); $num_rows = $db->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $row = $db->query_result_rowdata($result, $i); $fieldModel = new self(); $fieldModel->initialize($row); $fieldModelList[] = $fieldModel; } return $fieldModelList; }
/** * Loads a module object by name. * The only difference with exists() is that the $module parameter will be * assigned the found module. * * @param string $moduleName The name of the module to find (ex: content) * @param mixed $module This parameter will receive the found module object * @param array|string * Either an array of path or a single path string. These will be * used as additionnal locations that will be looked into * @param boolean $showError * If true an error will be shown if the module it not found. * @return eZModule The eZModule object, or null if the module wasn't found * @see exists() */ static function findModule($moduleName, $module = null, $pathList = null, $showError = false) { if ($pathList === null) { $pathList = array(); } else { if (!is_array($pathList)) { $pathList = array($pathList); } } $searchPathList = self::globalPathList(); if ($searchPathList === null) { $searchPathList = array(); } $searchPathList = array_merge($searchPathList, $pathList); $triedList = array(); $triedDirList = array(); $foundADir = false; foreach ($searchPathList as $path) { $dir = "{$path}/{$moduleName}"; $file = "{$dir}/module.php"; if (file_exists($file)) { if ($module === null) { $module = new self($path, $file, $moduleName, false); } else { $module->initialize($path, $file, $moduleName, false); } return $module; } else { if (!file_exists($dir)) { $triedDirList[] = $dir; } else { $foundADir = true; $triedList[] = $dir; } } } $msg = "Could not find module named '{$moduleName}'"; if ($foundADir) { $msg = "\nThese directories had a directory named '{$moduleName}' but did not contain the module.php file:\n" . implode(", ", $triedList) . "\n" . "This usually means it is missing or has a wrong name."; if (count($triedDirList) > 0) { $msg .= "\n\nThese directories were tried too but none of them exists:\n" . implode(', ', $triedDirList); } } else { if (count($triedDirList) > 0) { $msg .= "\nThese directories were tried but none of them exists:\n" . implode(", ", $triedDirList); } } if ($showError) { eZDebug::writeWarning($msg); } return null; }
/** * Get all the link related to module based on type * @param Integer Module ID * @param mixed String or List of types to select * @param Map Key-Value pair to use for formating the link url */ static function getAllByType($tabid, $type = false, $parameters = false) { global $adb; self::__initSchema(); $multitype = false; if ($type) { // Multiple link type selection? if (is_array($type)) { $multitype = true; if ($tabid === self::IGNORE_MODULE) { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE linktype IN (' . Vtiger_Utils::implodestr('?', count($type), ',') . ')', array($adb->flatten_array($type))); } else { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE tabid=? AND linktype IN (' . Vtiger_Utils::implodestr('?', count($type), ',') . ')', array($tabid, $adb->flatten_array($type))); } } else { // Single link type selection if ($tabid === self::IGNORE_MODULE) { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE linktype=?', array($type)); } else { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE tabid=? AND linktype=?', array($tabid, $type)); } } } else { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE tabid=?', array($tabid)); } $strtemplate = new Vtiger_StringTemplate(); if ($parameters) { foreach ($parameters as $key => $value) { $strtemplate->assign($key, $value); } } $instances = array(); if ($multitype) { foreach ($type as $t) { $instances[$t] = array(); } } while ($row = $adb->fetch_array($result)) { $instance = new self(); $instance->initialize($row); if ($parameters) { $instance->linkurl = $strtemplate->merge($instance->linkurl); $instance->linkicon = $strtemplate->merge($instance->linkicon); } if ($multitype) { $instances[$instance->linktype][] = $instance; } else { $instances[] = $instance; } } return $instances; }
/** * Get all block instances associated with the module * @param Vtiger_Module Instance of the module */ static function getAllForModule($moduleInstance) { global $adb; $instances = false; /** START 大熊追加 151217 ***/ //ユーザごとの部署の取得 $query_users = "SELECT `division` FROM `vtiger_users`"; $query_users .= " WHERE TRUE "; $query_users .= " AND `id` = {$_SESSION['authenticated_user_id']} "; $result_users = $adb->pquery($query_users); $row_users = $adb->fetch_array($result_users); $division_name = $row_users['division']; /** END 大熊追加 151217 ***/ # $query = "SELECT * FROM vtiger_blocks WHERE tabid=? ORDER BY sequence"; /** START 大熊追加 151217 ***/ $query = " SELECT * FROM vtiger_blocks WHERE tabid=? "; switch ($division_name) { case '101:求人広告': $query .= " AND `blocklabel` NOT IN ('WS', 'SC') "; break; case '202:Webコミュ': $query .= " AND `blocklabel` NOT IN ('HR', 'SC') "; break; case '201:風評コンサル': $query .= " AND `blocklabel` NOT IN ('HR', 'SC') "; break; case '203:サロコン': $query .= " AND `blocklabel` NOT IN ('HR', 'WS') "; break; } //End switch $query .= " ORDER BY sequence "; /** END 大熊追加 151217 ***/ $queryParams = array($moduleInstance->id); $result = $adb->pquery($query, $queryParams); for ($index = 0; $index < $adb->num_rows($result); ++$index) { $instance = new self(); $instance->initialize($adb->fetch_array($result), $moduleInstance); $instances[] = $instance; } return $instances; }
/** * Create a new instance * * @param MiniGameId $id * @param string $word * @return Hangman */ public static function createGame(MiniGameId $id, $word) { $hangman = new self(); $hangman->initialize($id, $word); return $hangman; }
/** * 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; }
/** * Function returns the Reports Model instance * @param <Number> $recordId * @param <String> $module * @return <Reports_Record_Model> */ public static function getInstanceById($recordId) { $db = PearDatabase::getInstance(); $self = new self(); $reportResult = $db->pquery('SELECT * FROM vtiger_report WHERE reportid = ?', array($recordId)); if ($db->num_rows($reportResult)) { $values = $db->query_result_rowdata($reportResult, 0); $module = Vtiger_Module_Model::getInstance('Reports'); $self->setData($values)->setId($values['reportid'])->setModuleFromInstance($module); $self->initialize(); } return $self; }
static function listAll($parent) { global $adb, $log; $instances = Array(); $result = $adb->pquery('SELECT * FROM vtiger_modtracker_detail WHERE id=?', Array($parent->id)); if($adb->num_rows($result)) { while($rowmap = $adb->fetch_array($result)) { $instance = new self($parent); $instance->initialize($rowmap); // Pick the records which has view access if($instance->isViewPermitted()) { $instances[] = $instance; } } } return $instances; }
/** * Get all the link related to module based on type * @param Integer Module ID * @param mixed String or List of types to select * @param Map Key-Value pair to use for formating the link url */ static function getAllByType($tabid, $type = false, $parameters = false) { global $adb, $current_user; self::__initSchema(); $multitype = false; $orderby = " order by linktype,sequence"; if ($type) { // Multiple link type selection? if (is_array($type)) { $multitype = true; if ($tabid === self::IGNORE_MODULE) { $sql = 'SELECT * FROM vtiger_links WHERE linktype IN (' . Vtiger_Utils::implodestr('?', count($type), ',') . ') '; $params = $type; $permittedTabIdList = getPermittedModuleIdList(); if (count($permittedTabIdList) > 0 && $current_user->is_admin !== 'on') { $sql .= ' and tabid IN (' . Vtiger_Utils::implodestr('?', count($permittedTabIdList), ',') . ')'; $params[] = $permittedTabIdList; } $result = $adb->pquery($sql . $orderby, array($adb->flatten_array($params))); } else { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE tabid=? AND linktype IN (' . Vtiger_Utils::implodestr('?', count($type), ',') . ')' . $orderby, array($tabid, $adb->flatten_array($type))); } } else { // Single link type selection if ($tabid === self::IGNORE_MODULE) { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE linktype=?' . $orderby, array($type)); } else { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE tabid=? AND linktype=?' . $orderby, array($tabid, $type)); } } } else { $result = $adb->pquery('SELECT * FROM vtiger_links WHERE tabid=?' . $orderby, array($tabid)); } $strtemplate = new Vtiger_StringTemplate(); if ($parameters) { foreach ($parameters as $key => $value) { $strtemplate->assign($key, $value); } } $instances = array(); if ($multitype) { foreach ($type as $t) { $instances[$t] = array(); } } while ($row = $adb->fetch_array($result)) { $instance = new self(); $instance->initialize($row); if (!empty($row['handler_path']) && isFileAccessible($row['handler_path'])) { checkFileAccessForInclusion($row['handler_path']); require_once $row['handler_path']; $linkData = new Vtiger_LinkData($instance, $current_user); $ignore = call_user_func(array($row['handler_class'], $row['handler']), $linkData); if (!$ignore) { self::log("Ignoring Link ... " . var_export($row, true)); continue; } } if ($parameters) { $instance->linkurl = $strtemplate->merge($instance->linkurl); $instance->linkicon = $strtemplate->merge($instance->linkicon); } if ($multitype) { $instances[$instance->linktype][] = $instance; } else { $instances[] = $instance; } } return $instances; }
public static function getInstanceFromFieldId($fieldId, $moduleTabId = false) { $fieldModel = Vtiger_Cache::get('FieldModel', $fieldId); if ($fieldModel) { return $fieldModel; } $field = Vtiger_Functions::getModuleFieldInfoWithId($fieldId); $fieldModel = new self(); $fieldModel->initialize($field); Vtiger_Cache::set('FieldModel', $fieldId, $fieldModel); return $fieldModel; }
/** * Get all instances of filter for the module * @param Vtiger_Module Instance of module */ static function getAllForModule($moduleInstance) { global $adb; $instances = false; $query = "SELECT * FROM vtiger_customview WHERE entitytype=?"; $queryParams = array($moduleInstance->name); $result = $adb->pquery($query, $queryParams); for ($index = 0; $index < $adb->num_rows($result); ++$index) { $instance = new self(); $instance->initialize($adb->fetch_array($result), $moduleInstance); $instances[] = $instance; } return $instances; }
/** * Returns ilChatroom by given $room_id * * @global ilDBMySQL $ilDB * @param integer $room_id * @return ilChatroom */ public static function byRoomId($room_id, $initObject = false) { global $ilDB; $query = 'SELECT * FROM ' . self::$settingsTable . ' WHERE room_id = %s'; $types = array('integer'); $values = array($room_id); $rset = $ilDB->queryF($query, $types, $values); if ($row = $ilDB->fetchAssoc($rset)) { $room = new self(); $room->initialize($row); if ($initObject) { $room->object = ilObjectFactory::getInstanceByObjId($row['object_id']); } return $room; } }
/** * Get instance by id or name * @param mixed id or name of the module */ static function getInstance($value) { $instance = false; $data = Vtiger_Functions::getModuleData($value); if ($data) { $instance = new self(); $instance->initialize($data); } return $instance; }
/** * Extract the links of module for export. */ static function getAllForExport($tabid) { $adb = PearDatabase::getInstance(); $result = $adb->pquery('SELECT * FROM vtiger_links WHERE tabid=?', array($tabid)); $links = array(); while ($row = $adb->fetch_array($result)) { $instance = new self(); $instance->initialize($row); $links[] = $instance; } return $links; }