Esempio n. 1
0
 /**
  * takes an associative array and creates a contact object
  *
  * the function extract all the params it needs to initialize the create a
  * contact object. the params array could contain additional unused name/value
  * pairs
  *
  * @param array  $params   (reference ) an assoc array of name/value pairs
  * @param array  $ids      (reference ) the array that holds all the db ids
  *
  * @return object   CRM_Core_BAO_Call object
  * @access public
  * @static
  */
 function add(&$params, &$ids)
 {
     if (!CRM_Core_BAO_Phonecall::dataExists($params)) {
         return null;
     }
     $call =& new CRM_Core_DAO_Phonecall();
     $call->copyValues($params);
     if (CRM_Utils_Array::value('phone_number', $params)) {
         $call->phone_id = null;
     }
     $call->id = CRM_Utils_Array::value('call', $ids);
     return $call->save();
 }
Esempio n. 2
0
 /**
  * This function is called when action is update or new
  * 
  * return null
  * @access public
  */
 function edit()
 {
     //set the path depending on open activity or activity history (view mode)
     $history = CRM_Utils_Request::retrieve('history', $this);
     // set the userContext stack
     $session =& CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/contact/view/activity', 'show=1&action=browse&reset=1&history=' . $history . '&cid=' . $this->_contactId);
     $session->pushUserContext($url);
     if (CRM_Utils_Request::retrieve('confirmed', $form, '', '', 'GET')) {
         require_once 'CRM/Core/BAO/Phonecall.php';
         CRM_Core_BAO_Phonecall::del($this->_id);
         CRM_Utils_System::redirect($url);
     }
     $controller =& new CRM_Core_Controller_Simple('CRM_Activity_Form_Phonecall', ts('Contact Calls'), $this->_action);
     $controller->reset();
     $controller->setEmbedded(true);
     $controller->set('contactId', $this->_contactId);
     $controller->set('id', $this->_id);
     $controller->set('pid', $this->get('pid'));
     $controller->set('log', $this->get('log'));
     $controller->process();
     $controller->run();
 }
Esempio n. 3
0
 /**
  * Delete a contact and all its associated records
  * 
  * @param  int  $id id of the contact to delete
  *
  * @return boolean true if contact deleted, false otherwise
  * @access public
  * @static
  */
 function deleteContact($id)
 {
     require_once 'CRM/Core/BAO/EmailHistory.php';
     require_once 'CRM/Core/BAO/Meeting.php';
     require_once 'CRM/Core/BAO/Phonecall.php';
     // make sure we have edit permission for this contact
     // before we delete
     if (!CRM_Contact_BAO_Contact::permissionedContact($id, CRM_CORE_PERMISSION_EDIT)) {
         return false;
     }
     require_once 'CRM/Utils/Hook.php';
     $contact =& new CRM_Contact_DAO_Contact();
     $contact->id = $id;
     if (!$contact->find(true)) {
         return false;
     }
     $contactType = $contact->contact_type;
     CRM_Utils_Hook::pre('delete', $contactType, $id);
     CRM_Core_DAO::transaction('BEGIN');
     // do a top down deletion
     CRM_Mailing_Event_BAO_Subscribe::deleteContact($id);
     CRM_Contact_BAO_GroupContact::deleteContact($id);
     CRM_Contact_BAO_SubscriptionHistory::deleteContact($id);
     CRM_Contact_BAO_Relationship::deleteContact($id);
     CRM_Contribute_BAO_Contribution::deleteContact($id);
     CRM_Core_BAO_Note::deleteContact($id);
     CRM_Core_DAO::deleteEntityContact('CRM_Core_DAO_CustomValue', $id);
     CRM_Core_DAO::deleteEntityContact('CRM_Core_DAO_ActivityHistory', $id);
     require_once 'CRM/Core/BAO/UFMatch.php';
     CRM_Core_BAO_UFMatch::deleteContact($id);
     // need to remove them from email, meeting and phonecall
     CRM_Core_BAO_EmailHistory::deleteContact($id);
     CRM_Core_BAO_Meeting::deleteContact($id);
     CRM_Core_BAO_Phonecall::deleteContact($id);
     // location shld be deleted after phonecall, since fields in phonecall are
     // fkeyed into location/phone.
     CRM_Core_BAO_Location::deleteContact($id);
     // fix household and org primary contact ids
     foreach ($GLOBALS['_CRM_CONTACT_BAO_CONTACT']['misc'] as $name) {
         require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $name) . ".php";
         eval('$object =& new CRM_Contact_DAO_' . $name . '( );');
         $object->primary_contact_id = $id;
         $object->find();
         while ($object->fetch()) {
             // we need to set this to null explicitly
             $object->primary_contact_id = 'null';
             $object->save();
         }
     }
     require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_BAO_" . $contactType) . ".php";
     eval('$object =& new CRM_Contact_BAO_' . $contactType . '( );');
     $object->contact_id = $contact->id;
     $object->delete();
     $contact->delete();
     //delete the contact id from recently view
     CRM_Utils_Recent::del($id);
     CRM_Core_DAO::transaction('COMMIT');
     CRM_Utils_Hook::post('delete', $contactType, $contact->id, $contact);
     return true;
 }