/** * Takes a bunch of params that are needed to match certain criteria and * retrieves the relevant objects. Typically the valid params are only * contact_id. We'll tweak this function to be more full featured over a period * of time. This is the inverse function of create. It also stores all the retrieved * values in the default array * * @param array $params (reference ) an assoc array of name/value pairs * @param array $defaults (reference ) an assoc array to hold the flattened values * * @return object CRM_Core_BAO_LocationType object on success, null otherwise * @access public * @static */ static function retrieve(&$params, &$defaults) { $extension = new CRM_Core_DAO_Extension(); $extension->copyValues($params); if ($extension->find(TRUE)) { CRM_Core_DAO::storeValues($extension, $defaults); return $extension; } return NULL; }
/** * Auto-generate a place-holder for a missing extension using info from * database. * * @param $key * @return CRM_Extension_Info|NULL */ public function createInfoFromDB($key) { $dao = new CRM_Core_DAO_Extension(); $dao->full_name = $key; if ($dao->find(TRUE)) { $info = new CRM_Extension_Info($dao->full_name, $dao->type, $dao->name, $dao->label, $dao->file); return $info; } else { return NULL; } }
/** * Fetch stats about enabled components/extensions * Add info to the 'extensions' array */ private function extensionStats() { // Core components $config = CRM_Core_Config::singleton(); foreach ($config->enableComponents as $comp) { $this->stats['extensions'][] = array('name' => 'org.civicrm.component.' . strtolower($comp), 'enabled' => 1, 'version' => $this->stats['version']); } // Contrib extensions $mapper = CRM_Extension_System::singleton()->getMapper(); $dao = new CRM_Core_DAO_Extension(); $dao->find(); while ($dao->fetch()) { $info = $mapper->keyToInfo($dao->full_name); $this->stats['extensions'][] = array('name' => $dao->full_name, 'enabled' => $dao->is_active, 'version' => isset($info->version) ? $info->version : NULL); } }
/** * Get a list of all installed modules, including enabled and disabled ones * * @return array * CRM_Core_Module */ public function getModules() { $result = array(); $dao = new CRM_Core_DAO_Extension(); $dao->type = 'module'; $dao->find(); while ($dao->fetch()) { $result[] = new CRM_Core_Module($dao->full_name, $dao->is_active); } return $result; }
/** * Searches for and returnes installed extensions. * * @access private * * @param boolean $fullInfo provide full info (read XML files) if true, otherwise only DB stored data * * @return array list of extensions */ private function _discoverInstalled($fullInfo = FALSE) { $result = array(); $dao = new CRM_Core_DAO_Extension(); $dao->find(); // TODO need bool? while ($dao->fetch()) { $ext = new CRM_Core_Extensions_Extension($dao->full_name, $dao->type, $dao->name, $dao->label, $dao->file, $dao->is_active); $ext->setInstalled(); $ext->setId((int) $dao->id); if ($fullInfo) { if ($ext->hasXMLInfo()) { $ext->readXMLInfo(); } else { $ext->setMissing(); CRM_Core_Session::setStatus(ts('The extension %1 (%2) is listed as installed, but expected files(s) including info.xml are missing. Has this site been moved to a different server location?', array(1 => $dao->label, 2 => $dao->full_name)) . '<br/>'); } } $result[(int) $dao->id] = $ext; } return $result; }