Ejemplo n.º 1
0
 /**
  * Add the relationship type in the db.
  *
  * @param array $params
  *   (reference ) an assoc array of name/value pairs.
  * @param array $ids
  *   The array that holds all the db ids.
  *
  * @return CRM_Contact_DAO_RelationshipType
  */
 public static function add(&$params, &$ids)
 {
     //to change name, CRM-3336
     if (empty($params['label_a_b']) && !empty($params['name_a_b'])) {
         $params['label_a_b'] = $params['name_a_b'];
     }
     if (empty($params['label_b_a']) && !empty($params['name_b_a'])) {
         $params['label_b_a'] = $params['name_b_a'];
     }
     // set label to name if it's not set - but *only* for
     // ADD action. CRM-3336 as part from (CRM-3522)
     if (empty($ids['relationshipType'])) {
         if (empty($params['name_a_b']) && !empty($params['label_a_b'])) {
             $params['name_a_b'] = $params['label_a_b'];
         }
         if (empty($params['name_b_a']) && !empty($params['label_b_a'])) {
             $params['name_b_a'] = $params['label_b_a'];
         }
     }
     // action is taken depending upon the mode
     $relationshipType = new CRM_Contact_DAO_RelationshipType();
     $relationshipType->copyValues($params);
     // if label B to A is blank, insert the value label A to B for it
     if (!strlen(trim($strName = CRM_Utils_Array::value('name_b_a', $params)))) {
         $relationshipType->name_b_a = CRM_Utils_Array::value('name_a_b', $params);
     }
     if (!strlen(trim($strName = CRM_Utils_Array::value('label_b_a', $params)))) {
         $relationshipType->label_b_a = CRM_Utils_Array::value('label_a_b', $params);
     }
     $relationshipType->id = CRM_Utils_Array::value('relationshipType', $ids);
     $result = $relationshipType->save();
     CRM_Core_PseudoConstant::relationshipType('label', TRUE);
     CRM_Core_PseudoConstant::relationshipType('name', TRUE);
     CRM_Case_XMLProcessor::flushStaticCaches();
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Function to add the relationship type in the db
  *
  * @param array $params (reference ) an assoc array of name/value pairs
  * @param array $ids    the array that holds all the db ids
  *
  * @return object CRM_Contact_DAO_RelationshipType
  * @access public
  * @static
  *
  */
 static function add(&$params, &$ids)
 {
     //to change name, CRM-3336
     if (!CRM_Utils_Array::value('label_a_b', $params) && CRM_Utils_Array::value('name_a_b', $params)) {
         $params['label_a_b'] = $params['name_a_b'];
     }
     if (!CRM_Utils_Array::value('label_b_a', $params) && CRM_Utils_Array::value('name_b_a', $params)) {
         $params['label_b_a'] = $params['name_b_a'];
     }
     // set label to name if it's not set - but *only* for
     // ADD action. CRM-3336 as part from (CRM-3522)
     if (!CRM_Utils_Array::value('relationshipType', $ids)) {
         if (!CRM_Utils_Array::value('name_a_b', $params) && CRM_Utils_Array::value('label_a_b', $params)) {
             $params['name_a_b'] = $params['label_a_b'];
         }
         if (!CRM_Utils_Array::value('name_b_a', $params) && CRM_Utils_Array::value('label_b_a', $params)) {
             $params['name_b_a'] = $params['label_b_a'];
         }
     }
     // action is taken depending upon the mode
     $relationshipType = new CRM_Contact_DAO_RelationshipType();
     $relationshipType->copyValues($params);
     // if label B to A is blank, insert the value label A to B for it
     if (!strlen(trim($strName = CRM_Utils_Array::value('name_b_a', $params)))) {
         $relationshipType->name_b_a = CRM_Utils_Array::value('name_a_b', $params);
     }
     if (!strlen(trim($strName = CRM_Utils_Array::value('label_b_a', $params)))) {
         $relationshipType->label_b_a = CRM_Utils_Array::value('label_a_b', $params);
     }
     $relationshipType->id = CRM_Utils_Array::value('relationshipType', $ids);
     return $relationshipType->save();
 }