/**
  * Takes a bunch of params that are needed to match certain criteria and
  * retrieves the relevant objects. 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_Booking_DAO_ResourceConfigOtpion object on success, null otherwise
  * @access public
  * @static
  */
 static function retrieve(&$params, &$defaults)
 {
     $configOption = new CRM_Booking_DAO_ResourceConfigOption();
     $configOption->copyValues($params);
     if ($configOption->find(TRUE)) {
         CRM_Core_DAO::storeValues($configOption, $defaults);
         return $configOption;
     }
     return NULL;
 }
 /**
  * Browse all resources.
  *
  * @return void
  * @access public
  * @static
  */
 function browse($action = NULL)
 {
     $units = CRM_Booking_DAO_ResourceConfigOption::buildOptions('unit_id', 'create');
     // get all config option sorted by weight
     $configOptions = array();
     $dao = new CRM_Booking_DAO_ResourceConfigOption();
     $dao->set_id = $this->_sid;
     $dao->orderBy('weight');
     $dao->is_deleted = FALSE;
     $dao->find();
     while ($dao->fetch()) {
         $configOptions[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $configOptions[$dao->id]);
         $configOptions[$dao->id]['unit'] = CRM_Utils_Array::value(CRM_Utils_Array::value('unit_id', $configOptions[$dao->id]), $units);
         // form all action links
         $action = array_sum(array_keys($this->links()));
         // update enable/disable links.
         if ($dao->is_active) {
             $action -= CRM_Core_Action::ENABLE;
         } else {
             $action -= CRM_Core_Action::DISABLE;
         }
         $configOptions[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id, 'sid' => $this->_sid));
     }
     $this->assign('rows', $configOptions);
 }
 /**
  * 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['booking_resource_config_option'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }