public function reconcileUnknownModules()
 {
     $knownModules = array();
     if (array_key_exists(0, $this->moduleIndex) && is_array($this->moduleIndex[0])) {
         $knownModules = array_merge($knownModules, array_keys($this->moduleIndex[0]));
     }
     if (array_key_exists(1, $this->moduleIndex) && is_array($this->moduleIndex[1])) {
         $knownModules = array_merge($knownModules, array_keys($this->moduleIndex[1]));
     }
     $dao = new CRM_Core_DAO_Managed();
     if (!empty($knownModules)) {
         $in = CRM_Core_DAO::escapeStrings($knownModules);
         $dao->whereAdd("module NOT IN ({$in})");
     }
     $dao->find();
     while ($dao->fetch()) {
         $params = array('version' => 3, 'id' => $dao->entity_id);
         $result = civicrm_api($dao->entity_type, 'delete', $params);
         if ($result['is_error']) {
             $this->onApiError($params, $result);
         }
         CRM_Core_DAO::executeQuery('DELETE FROM civicrm_managed WHERE id = %1', array(1 => array($dao->id, 'Integer')));
     }
 }
Example #2
0
 /**
  * returns the list of fields that can be exported
  *
  * @access public
  * return array
  * @static
  */
 static function &export($prefix = false)
 {
     if (!self::$_export) {
         self::$_export = array();
         $fields = self::fields();
         foreach ($fields as $name => $field) {
             if (CRM_Utils_Array::value('export', $field)) {
                 if ($prefix) {
                     self::$_export['managed'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }
 /**
  * Update an entity which (a) is believed to exist and which (b) ought to be active.
  *
  * @param CRM_Core_DAO_Managed $dao
  * @param array $todo entity specification (per hook_civicrm_managedEntities)
  */
 public function updateExistingEntity($dao, $todo)
 {
     $policy = CRM_Utils_Array::value('update', $todo, 'always');
     $doUpdate = $policy == 'always';
     if ($doUpdate) {
         $defaults = array('id' => $dao->entity_id, 'is_active' => 1);
         $params = array_merge($defaults, $todo['params']);
         $result = civicrm_api($dao->entity_type, 'create', $params);
         if ($result['is_error']) {
             $this->onApiError($dao->entity_type, 'create', $params, $result);
         }
     }
     if (isset($todo['cleanup'])) {
         $dao->cleanup = $todo['cleanup'];
         $dao->update();
     }
 }