示例#1
0
 /**
  * takes an associative array and creates a note object
  *
  * the function extract all the params it needs to initialize the create a
  * note object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params         (reference ) an assoc array of name/value pairs
  *
  * @return object CRM_Core_BAO_Note object
  * @access public
  * @static
  */
 function &add(&$params)
 {
     $dataExists = CRM_Core_BAO_Note::dataExists($params);
     if (!$dataExists) {
         return null;
     }
     $note =& new CRM_Core_BAO_Note();
     $params['modified_date'] = date("Ymd");
     $params['entity_id'] = $params['entity_id'];
     $params['entity_table'] = $params['entity_table'];
     $note->copyValues($params);
     $session =& CRM_Core_Session::singleton();
     $note->contact_id = $session->get('userID');
     if (!$note->contact_id) {
         if ($params['entity_table'] == 'civicrm_contact') {
             $note->contact_id = $params['entity_id'];
         } else {
             CRM_Utils_System::statusBounce(ts('We could not find your logged in user ID'));
         }
     }
     $note->save();
     return $note;
 }