Exemplo n.º 1
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $dao = new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('SMS Sent');
     if ($dao->find(TRUE)) {
         $cid = $dao->entity_id;
     }
     $dao = new CRM_SMS_DAO_History();
     $dao->id = $id;
     if ($dao->find(TRUE)) {
         $this->assign('fromName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contact_id, 'display_name'));
         $this->assign('toName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name'));
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         // also add the cid params to the Menu array
         CRM_Core_Menu::addParam('cid', $cid);
     }
     return parent::run();
 }
Exemplo n.º 2
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
     $id = CRM_Utils_Request::retrieve('id', $this);
     $dao =& new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('SMS Sent');
     if ($dao->find(true)) {
         $cid = $dao->entity_id;
     }
     require_once 'CRM/SMS/DAO/History.php';
     $dao =& new CRM_SMS_DAO_History();
     $dao->id = $id;
     if ($dao->find(true)) {
         $this->assign('fromName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $dao->contact_id, 'display_name'));
         $this->assign('toName', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name'));
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         require_once 'CRM/Utils/Menu.php';
         // also add the cid params to the Menu array
         CRM_Utils_Menu::addParam('cid', $cid);
         // create menus ..
         $startWeight = CRM_Utils_Menu::getMaxWeight('civicrm/contact/view');
         $startWeight++;
         require_once 'CRM/Core/BAO/CustomGroup.php';
         CRM_Core_BAO_CustomGroup::addMenuTabs(CRM_Contact_BAO_Contact::getContactType($cid), 'civicrm/contact/view/cd', $startWeight);
     }
     parent::run();
 }
Exemplo n.º 3
0
 /**
  * Build all the data structures needed to build the form.
  */
 public function preProcess()
 {
     // reset action from the session
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'update');
     $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
     $rcid = CRM_Utils_Request::retrieve('rcid', 'Positive', $this);
     $rcid = $rcid ? "&id={$rcid}" : '';
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/user', "reset=1{$rcid}"));
     if ($this->_contactId) {
         $contact = new CRM_Contact_DAO_Contact();
         $contact->id = $this->_contactId;
         if (!$contact->find(TRUE)) {
             CRM_Core_Error::statusBounce(ts('contact does not exist: %1', array(1 => $this->_contactId)));
         }
         $this->_contactType = $contact->contact_type;
         // check for permissions
         if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
             CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
         }
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
         CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
     } else {
         CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
     }
 }
Exemplo n.º 4
0
 /**
  * Heart of the viewing process.
  *
  * The runner gets all the meta data for the contact and calls the appropriate type of page to view.
  */
 public function preProcess()
 {
     if (!$this->_contactId) {
         CRM_Core_Error::fatal(ts('You must be logged in to view this page.'));
     }
     list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
     $this->set('displayName', $displayName);
     $this->set('contactImage', $contactImage);
     CRM_Utils_System::setTitle(ts('Dashboard - %1', array(1 => $displayName)));
     $this->assign('recentlyViewed', FALSE);
 }
 function preProcess()
 {
     if (!$this->_contactId) {
         CRM_Core_Error::fatal(ts('You must be logged in to view this page.'));
     }
     list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
     $this->set('displayName', $displayName);
     $this->set('contactImage', $contactImage);
     CRM_Utils_System::setTitle(ts('Dashboard - %1', array(1 => $displayName)));
     $this->assign('recentlyViewed', FALSE);
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/pcp/dashboard', 'reset=1'));
 }
Exemplo n.º 6
0
 /**
  * @param $id
  * @param string $table
  *
  * @return array|null
  */
 static function &lastModified($id, $table = 'civicrm_contact')
 {
     $log = new CRM_Core_DAO_Log();
     $log->entity_table = $table;
     $log->entity_id = $id;
     $log->orderBy('modified_date desc');
     $log->limit(1);
     $result = CRM_Core_DAO::$_nullObject;
     if ($log->find(TRUE)) {
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id);
         $result = array('id' => $log->modified_id, 'name' => $displayName, 'image' => $contactImage, 'date' => $log->modified_date);
     }
     return $result;
 }
Exemplo n.º 7
0
 /**
  * This function is called when action is browse
  * 
  * return null
  * @access public
  */
 function browse()
 {
     require_once 'CRM/Core/DAO/Log.php';
     $log =& new CRM_Core_DAO_Log();
     $log->entity_table = 'civicrm_contact';
     $log->entity_id = $this->_contactId;
     $log->orderBy('modified_date desc');
     $log->find();
     $logEntries = array();
     while ($log->fetch()) {
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id);
         $logEntries[] = array('id' => $log->modified_id, 'name' => $displayName, 'image' => $contactImage, 'date' => $log->modified_date);
     }
     $this->assign('logCount', count($logEntries));
     $this->assign_by_ref('log', $logEntries);
 }
Exemplo n.º 8
0
 /**
  * Run the page.
  *
  * This method is called after the page is created.
  *
  * @return void
  * @access public
  *
  */
 function run()
 {
     // get the callback, module and activity id
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $dao = new CRM_Core_DAO_ActivityHistory();
     $dao->activity_id = $id;
     $dao->activity_type = ts('Email Sent');
     if ($dao->find(TRUE)) {
         $cid = $dao->entity_id;
     }
     $dao = new CRM_Core_DAO_EmailHistory();
     $dao->id = $id;
     if ($dao->find(TRUE)) {
         // get the display name and email for the contact
         list($toContactName, $toContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($cid);
         if (!trim($toContactName)) {
             $toContactName = $toContactEmail;
         }
         if (trim($toContactEmail)) {
             $toContactName = "\"{$toContactName}\" <{$toContactEmail}>";
         }
         $this->assign('toName', $toContactName);
         // get the display name and email for the contact
         list($fromContactName, $fromContactEmail, $toDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($dao->contact_id);
         if (!trim($fromContactEmail)) {
             CRM_Core_Error::statusBounce(ts('Your user record does not have a valid email address'));
         }
         if (!trim($fromContactName)) {
             $fromContactName = $fromContactEmail;
         }
         $this->assign('fromName', "\"{$fromContactName}\" <{$fromContactEmail}>");
         $this->assign('sentDate', $dao->sent_date);
         $this->assign('subject', $dao->subject);
         $this->assign('message', $dao->message);
         // get the display name and images for the contact
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
         // also add the cid params to the Menu array
         CRM_Core_Menu::addParam('cid', $cid);
     }
     return parent::run();
 }
Exemplo n.º 9
0
 /**
  * This function is called when action is browse
  *
  * return null
  * @access public
  */
 function browse()
 {
     $loggingReport = CRM_Core_BAO_Log::useLoggingReport();
     $this->assign('useLogging', $loggingReport);
     if ($loggingReport) {
         $this->assign('instanceUrl', CRM_Utils_System::url("civicrm/report/instance/{$loggingReport}", "reset=1&force=1&snippet=4&section=2&altered_contact_id_op=eq&altered_contact_id_value={$this->_contactId}&cid={$this->_contactId}", FALSE, NULL, FALSE));
         return;
     }
     $log = new CRM_Core_DAO_Log();
     $log->entity_table = 'civicrm_contact';
     $log->entity_id = $this->_contactId;
     $log->orderBy('modified_date desc');
     $log->find();
     $logEntries = array();
     while ($log->fetch()) {
         list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id);
         $logEntries[] = array('id' => $log->modified_id, 'name' => $displayName, 'image' => $contactImage, 'date' => $log->modified_date);
     }
     $this->assign('logCount', count($logEntries));
     $this->assign_by_ref('log', $logEntries);
 }
Exemplo n.º 10
0
 function preProcess()
 {
     $params = array();
     $defaults = array();
     $ids = array();
     $session =& CRM_Core_Session::singleton();
     $uid = $session->get('userID');
     if (!$uid) {
         require_once 'CRM/Utils/System.php';
         CRM_Utils_System::setUFMessage(ts('We could not find a user id. You must be logged in to access the CiviCRM Home Page and menus.'));
         CRM_Core_Error::statusBounce(ts('We could not find a user id. You must be logged in to access the CiviCRM Home Page and menus.'));
     }
     $this->assign('contactId', $uid);
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'view');
     $this->assign('action', $this->_action);
     // a user can always view their own activity history
     // if they have access CiviCRM permission
     $this->_permission = CRM_Core_Permission::VIEW;
     // make the permission edit if the user has edit permission on the contact
     require_once 'CRM/Contact/BAO/Contact/Permission.php';
     if (CRM_Contact_BAO_Contact_Permission::allow($uid, CRM_Core_Permission::EDIT)) {
         $this->_permission = CRM_Core_Permission::EDIT;
     }
     $displayName = $this->get('displayName');
     list($displayName, $contactImage, $contactType) = CRM_Contact_BAO_Contact::getDisplayAndImage($uid, true);
     $this->set('displayName', $displayName);
     $this->set('contactImage', $contactImage);
     CRM_Utils_System::setTitle($contactImage . ' ' . $displayName, $displayName);
     CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $uid), $uid, $contactType, $uid, $displayName);
     // call hook to get html from other modules
     require_once 'CRM/Utils/Hook.php';
     $contentPlacement = CRM_Utils_Hook::DASHBOARD_BELOW;
     // ignored but needed to prevent warnings
     $html = CRM_Utils_Hook::dashboard($uid, $contentPlacement);
     if (is_array($html)) {
         $this->assign_by_ref('hookContent', $html);
         $this->assign('hookContentPlacement', $contentPlacement);
     }
 }
Exemplo n.º 11
0
 /**
  * Pre processing work done here.
  *
  * Gets session variables for table name, id of entity in table, type of entity and stores them.
  */
 public function preProcess()
 {
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     $this->_multiRecordDisplay = CRM_Utils_Request::retrieve('multiRecordDisplay', 'String', $this);
     if ($this->_cdType || $this->_multiRecordDisplay == 'single') {
         if ($this->_cdType) {
             $this->assign('cdType', TRUE);
         }
         // NOTE : group id is not stored in session from within CRM_Custom_Form_CustomData::preProcess func
         // this is due to some condition inside it which restricts it from saving in session
         // so doing this for multi record edit action
         $entityId = CRM_Utils_Request::retrieve('entityID', 'Positive', $this);
         if (!empty($entityId)) {
             $subType = CRM_Contact_BAO_Contact::getContactSubType($entityId, ',');
         }
         CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, NULL, NULL, $entityId);
         if ($this->_multiRecordDisplay) {
             $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this);
             $this->_tableID = $this->_entityId;
             $this->_contactType = CRM_Contact_BAO_Contact::getContactType($this->_tableID);
             $mode = CRM_Utils_Request::retrieve('mode', 'String', $this);
             $hasReachedMax = CRM_Core_BAO_CustomGroup::hasReachedMaxLimit($this->_groupID, $this->_tableID);
             if ($hasReachedMax && $mode == 'add') {
                 CRM_Core_Error::statusBounce(ts('The maximum record limit is reached'));
             }
             $this->_copyValueId = CRM_Utils_Request::retrieve('copyValueId', 'Positive', $this);
             $groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_groupID);
             $mode = CRM_Utils_Request::retrieve('mode', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
             $mode = ucfirst($mode);
             CRM_Utils_System::setTitle(ts('%1 %2 Record', array(1 => $mode, 2 => $groupTitle)));
             if (!empty($_POST['hidden_custom'])) {
                 $this->assign('postedInfo', TRUE);
             }
         }
         return;
     }
     $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE);
     $this->_tableID = CRM_Utils_Request::retrieve('tableId', 'Positive', $this, TRUE);
     $this->_contactType = CRM_Contact_BAO_Contact::getContactType($this->_tableID);
     $this->_contactSubType = CRM_Contact_BAO_Contact::getContactSubType($this->_tableID, ',');
     $this->assign('contact_type', $this->_contactType);
     $this->assign('contact_subtype', $this->_contactSubType);
     list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_tableID);
     CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
     // when custom data is included in this page
     if (!empty($_POST['hidden_custom'])) {
         for ($i = 1; $i <= $_POST['hidden_custom_group_count'][$this->_groupID]; $i++) {
             CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_contactSubType, $i, $this->_contactType, $this->_tableID);
             CRM_Custom_Form_CustomData::buildQuickForm($this);
             CRM_Custom_Form_CustomData::setDefaultValues($this);
         }
     }
 }
Exemplo n.º 12
0
 function fixFormValues()
 {
     // if this search has been forced
     // then see if there are any get values, and if so over-ride the post values
     // note that this means that GET over-rides POST :)
     // we fix date_to here if set to be the end of the day, i.e. 23:59:59
     if (!CRM_Utils_System::isNull($this->_formValues['contribution_date_to'])) {
         $this->_formValues['contribution_date_to']['H'] = 23;
         $this->_formValues['contribution_date_to']['i'] = 59;
         $this->_formValues['contribution_date_to']['s'] = 59;
     }
     if (!$this->_force) {
         return;
     }
     $nullObject = null;
     $status = CRM_Utils_Request::retrieve('status', $nullObject);
     if ($status) {
         switch ($status) {
             case 'Valid':
             case 'Cancelled':
             case 'All':
                 $this->_formValues['contribution_status'] = $status;
                 $this->_defaults['contribution_status'] = $status;
                 break;
         }
     }
     $cid = CRM_Utils_Request::retrieve('cid', $nullObject);
     if ($cid) {
         $cid = CRM_Utils_Type::escape($cid, 'Integer');
         if ($cid > 0) {
             $this->_formValues['contact_id'] = $cid;
             list($display, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($cid);
             $this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name');
             // also assign individual mode to the template
             $this->_single = true;
         }
     }
     $fromDate = CRM_Utils_Request::retrieve('start', $nullObject);
     if ($fromDate) {
         $fromDate = CRM_Utils_Type::escape($fromDate, 'Timestamp');
         $date = CRM_Utils_Date::unformat($fromDate, '');
         $this->_formValues['contribution_date_from'] = $date;
         $this->_defaults['contribution_date_from'] = $date;
     }
     $toDate = CRM_Utils_Request::retrieve('end', $nullObject);
     if ($toDate) {
         $toDate = CRM_Utils_Type::escape($toDate, 'Timestamp');
         $date = CRM_Utils_Date::unformat($toDate, '');
         $this->_formValues['contribution_date_to'] = $date;
         $this->_defaults['contribution_date_to'] = $date;
         $this->_formValues['contribution_date_to']['H'] = 23;
         $this->_formValues['contribution_date_to']['i'] = 59;
         $this->_formValues['contribution_date_to']['s'] = 59;
     }
     $this->_limit = CRM_Utils_Request::retrieve('limit', $this);
 }
Exemplo n.º 13
0
 static function buildQuickForm(&$form)
 {
     if ($form->_context == 'caseActivity') {
         return;
     }
     if ($form->_context == 'standalone') {
         CRM_Contact_Form_NewContact::buildQuickForm($form);
     }
     $caseType = array('' => '-select-') + CRM_Case_PseudoConstant::caseType();
     $element = $form->add('select', 'case_type_id', ts('Case Type'), $caseType, TRUE, array('onchange' => "CRM.buildCustomData( 'Case', this.value );"));
     if ($form->_caseTypeId) {
         $element->freeze();
     }
     $caseStatus = CRM_Case_PseudoConstant::caseStatus();
     $form->add('select', 'status_id', ts('Case Status'), $caseStatus, TRUE);
     $form->add('text', 'duration', ts('Duration'), array('size' => 4, 'maxlength' => 8));
     $form->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
     if ($form->_currentlyViewedContactId) {
         list($displayName) = CRM_Contact_BAO_Contact::getDisplayAndImage($form->_currentlyViewedContactId);
         $form->assign('clientName', $displayName);
     }
     $form->addDate('start_date', ts('Case Start Date'), TRUE, array('formatType' => 'activityDateTime'));
     $form->add('select', 'medium_id', ts('Medium'), CRM_Case_PseudoConstant::encounterMedium(), TRUE);
     // calling this field activity_location to prevent conflict with contact location fields
     $form->add('text', 'activity_location', ts('Location'), CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'location'));
     $form->addWysiwyg('activity_details', ts('Details'), array('rows' => 4, 'cols' => 60), FALSE);
     $form->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
 }
Exemplo n.º 14
0
 /**
  * Given a UF user object, make sure there is a contact
  * object for this user. If the user has new values, we need
  * to update the CRM DB with the new values
  *
  * @param Object $user
  *   The drupal user object.
  * @param bool $update
  *   Has the user object been edited.
  * @param $uf
  *
  * @param $ctype
  * @param bool $isLogin
  */
 public static function synchronize(&$user, $update, $uf, $ctype, $isLogin = FALSE)
 {
     $userSystem = CRM_Core_Config::singleton()->userSystem;
     $session = CRM_Core_Session::singleton();
     if (!is_object($session)) {
         CRM_Core_Error::fatal('wow, session is not an object?');
         return;
     }
     $userSystemID = $userSystem->getBestUFID($user);
     $uniqId = $userSystem->getBestUFUniqueIdentifier($user);
     // if the id of the object is zero (true for anon users in drupal)
     // have we already processed this user, if so early
     // return.
     $userID = $session->get('userID');
     $ufID = $session->get('ufID');
     if (!$update && $ufID == $userSystemID) {
         return;
     }
     //check do we have logged in user.
     $isUserLoggedIn = CRM_Utils_System::isUserLoggedIn();
     // reset the session if we are a different user
     if ($ufID && $ufID != $userSystemID) {
         $session->reset();
         //get logged in user ids, and set to session.
         if ($isUserLoggedIn) {
             $userIds = self::getUFValues();
             $session->set('ufID', CRM_Utils_Array::value('uf_id', $userIds, ''));
             $session->set('userID', CRM_Utils_Array::value('contact_id', $userIds, ''));
             $session->set('ufUniqID', CRM_Utils_Array::value('uf_name', $userIds, ''));
         }
     }
     // return early
     if ($userSystemID == 0) {
         return;
     }
     $ufmatch = self::synchronizeUFMatch($user, $userSystemID, $uniqId, $uf, NULL, $ctype, $isLogin);
     if (!$ufmatch) {
         return;
     }
     //make sure we have session w/ consistent ids.
     $ufID = $ufmatch->uf_id;
     $userID = $ufmatch->contact_id;
     $ufUniqID = '';
     if ($isUserLoggedIn) {
         $loggedInUserUfID = CRM_Utils_System::getLoggedInUfID();
         //are we processing logged in user.
         if ($loggedInUserUfID && $loggedInUserUfID != $ufID) {
             $userIds = self::getUFValues($loggedInUserUfID);
             $ufID = CRM_Utils_Array::value('uf_id', $userIds, '');
             $userID = CRM_Utils_Array::value('contact_id', $userIds, '');
             $ufUniqID = CRM_Utils_Array::value('uf_name', $userIds, '');
         }
     }
     //set user ids to session.
     $session->set('ufID', $ufID);
     $session->set('userID', $userID);
     $session->set('ufUniqID', $ufUniqID);
     // add current contact to recently viewed
     if ($ufmatch->contact_id) {
         list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) = CRM_Contact_BAO_Contact::getDisplayAndImage($ufmatch->contact_id, TRUE, TRUE);
         $otherRecent = array('imageUrl' => $contactImageUrl, 'subtype' => $contactSubtype, 'editUrl' => CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$ufmatch->contact_id}"));
         CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$ufmatch->contact_id}"), $ufmatch->contact_id, $contactType, $ufmatch->contact_id, $displayName, $otherRecent);
     }
 }
Exemplo n.º 15
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, false, 'add');
     $this->_dedupeButtonName = $this->getButtonName('refresh', 'dedupe');
     $this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
     $session =& CRM_Core_Session::singleton();
     if ($this->_action == CRM_Core_Action::ADD) {
         // check for add contacts permissions
         require_once 'CRM/Core/Permission.php';
         if (!CRM_Core_Permission::check('add contacts')) {
             CRM_Utils_System::permissionDenied();
             return;
         }
         $this->_contactType = CRM_Utils_Request::retrieve('ct', 'String', $this, true, null, 'REQUEST');
         if (!in_array($this->_contactType, array('Individual', 'Household', 'Organization'))) {
             CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
         }
         $this->_contactSubType = CRM_Utils_Request::retrieve('cst', 'String', $this);
         $this->_gid = CRM_Utils_Request::retrieve('gid', 'Integer', CRM_Core_DAO::$_nullObject, false, null, 'GET');
         $this->_tid = CRM_Utils_Request::retrieve('tid', 'Integer', CRM_Core_DAO::$_nullObject, false, null, 'GET');
         if ($this->_contactSubType) {
             CRM_Utils_System::setTitle(ts('New %1', array(1 => $this->_contactSubType)));
         } else {
             $title = ts('New Individual');
             if ($this->_contactType == 'Household') {
                 $title = ts('New Household');
             } else {
                 if ($this->_contactType == 'Organization') {
                     $title = ts('New Organization');
                 }
             }
             CRM_Utils_System::setTitle($title);
         }
         $session->pushUserContext(CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
         $this->_contactId = null;
     } else {
         //update mode
         if (!$this->_contactId) {
             $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, true);
         }
         if ($this->_contactId) {
             require_once 'CRM/Contact/BAO/Contact.php';
             $contact =& new CRM_Contact_DAO_Contact();
             $contact->id = $this->_contactId;
             if (!$contact->find(true)) {
                 CRM_Core_Error::statusBounce(ts('contact does not exist: %1', array(1 => $this->_contactId)));
             }
             $this->_contactType = $contact->contact_type;
             $this->_contactSubType = $contact->contact_sub_type;
             // check for permissions
             require_once 'CRM/Contact/BAO/Contact/Permission.php';
             if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
                 CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
             }
             list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
             CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
             $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId));
             $values = $this->get('values');
             // get contact values.
             if (!empty($values)) {
                 $this->_values = $values;
             } else {
                 $params = array('id' => $this->_contactId, 'contact_id' => $this->_contactId);
                 $contact = CRM_Contact_BAO_Contact::retrieve($params, $this->_values, true);
                 $this->set('values', $this->_values);
             }
         } else {
             CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
         }
     }
     $this->_editOptions = $this->get('contactEditOptions');
     if (CRM_Utils_System::isNull($this->_editOptions)) {
         require_once 'CRM/Core/BAO/Preferences.php';
         $this->_editOptions = CRM_Core_BAO_Preferences::valueOptions('contact_edit_options', true, null, false, 'name', true, 'AND v.filter = 0');
         $this->set('contactEditOptions', $this->_editOptions);
     }
     // build demographics only for Individual contact type
     if ($this->_contactType != 'Individual' && array_key_exists('Demographics', $this->_editOptions)) {
         unset($this->_editOptions['Demographics']);
     }
     // in update mode don't show notes
     if ($this->_contactId && array_key_exists('Notes', $this->_editOptions)) {
         unset($this->_editOptions['Notes']);
     }
     $this->assign('editOptions', $this->_editOptions);
     $this->assign('contactType', $this->_contactType);
     $this->assign('contactSubType', $this->_contactSubType);
     // get the location blocks.
     $this->_blocks = $this->get('blocks');
     if (CRM_Utils_System::isNull($this->_blocks)) {
         $this->_blocks = CRM_Core_BAO_Preferences::valueOptions('contact_edit_options', true, null, false, 'name', true, 'AND v.filter = 1');
         $this->set('blocks', $this->_blocks);
     }
     $this->assign('blocks', $this->_blocks);
     if (array_key_exists('CustomData', $this->_editOptions)) {
         //only custom data has preprocess hence directly call it
         CRM_Custom_Form_CustomData::preProcess($this, null, $this->_contactSubType, 1, $this->_contactType, $this->_contactId);
     }
     // this is needed for custom data.
     $this->assign('entityID', $this->_contactId);
     // also keep the convention.
     $this->assign('contactId', $this->_contactId);
     // location blocks.
     CRM_Contact_Form_Location::preProcess($this);
 }
Exemplo n.º 16
0
 /**
  * Test case for getDisplayAndImage( ).
  */
 public function testGetDisplayAndImage()
 {
     //get the contact params
     $params = $this->contactParams();
     //create contact
     $contact = CRM_Contact_BAO_Contact::create($params);
     $contactId = $contact->id;
     //get DisplayAndImage.
     list($displayName, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($contactId);
     $checkImage = CRM_Contact_BAO_Contact_Utils::getImage($params['contact_type'], FALSE, $contactId);
     $prefix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
     $suffix = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id');
     //build display name
     $paramsDisplayName = $prefix[$params['prefix_id']] . ' ' . $params['first_name'] . ' ' . $params['last_name'] . ' ' . $suffix[$params['suffix_id']];
     $this->assertEquals($displayName, $paramsDisplayName, 'Check For Display Name');
     $this->assertEquals($image, $checkImage, 'Check For Image');
     //cleanup DB by deleting the contact
     $this->contactDelete($contactId);
 }
Exemplo n.º 17
0
 public function fixFormValues()
 {
     if (!$this->_force) {
         return;
     }
     $caseStatus = CRM_Utils_Request::retrieve('status', 'Positive', CRM_Core_DAO::$_nullObject);
     if ($caseStatus) {
         $this->_formValues['case_status_id'] = $caseStatus;
         $this->_defaults['case_status_id'] = $caseStatus;
     }
     $caseType = CRM_Utils_Request::retrieve('type', 'Positive', CRM_Core_DAO::$_nullObject);
     if ($caseType) {
         $this->_formValues['case_type_id'] = (array) $caseType;
         $this->_defaults['case_type_id'] = (array) $caseType;
     }
     $caseFromDate = CRM_Utils_Request::retrieve('pstart', 'Date', CRM_Core_DAO::$_nullObject);
     if ($caseFromDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($caseFromDate);
         $this->_formValues['case_start_date_low'] = $date;
         $this->_defaults['case_start_date_low'] = $date;
     }
     $caseToDate = CRM_Utils_Request::retrieve('pend', 'Date', CRM_Core_DAO::$_nullObject);
     if ($caseToDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($caseToDate);
         $this->_formValues['case_start_date_high'] = $date;
         $this->_defaults['case_start_date_high'] = $date;
     }
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if ($cid) {
         $cid = CRM_Utils_Type::escape($cid, 'Integer');
         if ($cid > 0) {
             $this->_formValues['contact_id'] = $cid;
             list($display, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($cid);
             $this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name');
             // also assign individual mode to the template
             $this->_single = TRUE;
         }
     } else {
         // First, if "all" is stored in the session, default to all cases, otherwise default to no selection.
         $session = CRM_Core_Session::singleton();
         if (CRM_Utils_Request::retrieve('all', 'Positive', $session)) {
             $this->_formValues['case_owner'] = 1;
             $this->_defaults['case_owner'] = 1;
         } else {
             $this->_formValues['case_owner'] = 0;
             $this->_defaults['case_owner'] = 0;
         }
         // Now if case_owner is set in the url/post, use that instead.
         $caseOwner = CRM_Utils_Request::retrieve('case_owner', 'Positive', CRM_Core_DAO::$_nullObject);
         if ($caseOwner) {
             $this->_formValues['case_owner'] = $caseOwner;
             $this->_defaults['case_owner'] = $caseOwner;
         }
     }
 }
Exemplo n.º 18
0
 /**
  * build all the data structures needed to build the form
  *
  * @return void
  * @access public
  */
 function preProcess()
 {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add');
     $this->_dedupeButtonName = $this->getButtonName('refresh', 'dedupe');
     $this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
     $session = CRM_Core_Session::singleton();
     if ($this->_action == CRM_Core_Action::ADD) {
         // check for add contacts permissions
         if (!CRM_Core_Permission::check('add contacts')) {
             CRM_Utils_System::permissionDenied();
             CRM_Utils_System::civiExit();
         }
         $this->_contactType = CRM_Utils_Request::retrieve('ct', 'String', $this, TRUE, NULL, 'REQUEST');
         if (!in_array($this->_contactType, array('Individual', 'Household', 'Organization'))) {
             CRM_Core_Error::statusBounce(ts('Could not get a contact id and/or contact type'));
         }
         $this->_isContactSubType = FALSE;
         if ($this->_contactSubType = CRM_Utils_Request::retrieve('cst', 'String', $this)) {
             $this->_isContactSubType = TRUE;
         }
         if ($this->_contactSubType && !CRM_Contact_BAO_ContactType::isExtendsContactType($this->_contactSubType, $this->_contactType, TRUE)) {
             CRM_Core_Error::statusBounce(ts("Could not get a valid contact subtype for contact type '%1'", array(1 => $this->_contactType)));
         }
         $this->_gid = CRM_Utils_Request::retrieve('gid', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
         $this->_tid = CRM_Utils_Request::retrieve('tid', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
         $typeLabel = CRM_Contact_BAO_ContactType::contactTypePairs(TRUE, $this->_contactSubType ? $this->_contactSubType : $this->_contactType);
         $typeLabel = implode(' / ', $typeLabel);
         CRM_Utils_System::setTitle(ts('New %1', array(1 => $typeLabel)));
         $session->pushUserContext(CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
         $this->_contactId = NULL;
     } else {
         //update mode
         if (!$this->_contactId) {
             $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
         }
         if ($this->_contactId) {
             $defaults = array();
             $params = array('id' => $this->_contactId);
             $returnProperities = array('id', 'contact_type', 'contact_sub_type');
             CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_Contact', $params, $defaults, $returnProperities);
             if (!CRM_Utils_Array::value('id', $defaults)) {
                 CRM_Core_Error::statusBounce(ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId)));
             }
             $this->_contactType = CRM_Utils_Array::value('contact_type', $defaults);
             $this->_contactSubType = CRM_Utils_Array::value('contact_sub_type', $defaults);
             // check for permissions
             $session = CRM_Core_Session::singleton();
             if ($session->get('userID') != $this->_contactId && !CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) {
                 CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.'));
             }
             list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
             CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
             $context = CRM_Utils_Request::retrieve('context', 'String', $this);
             $qfKey = CRM_Utils_Request::retrieve('key', 'String', $this);
             $urlParams = 'reset=1&cid=' . $this->_contactId;
             if ($context) {
                 $urlParams .= "&context={$context}";
             }
             if (CRM_Utils_Rule::qfKey($qfKey)) {
                 $urlParams .= "&key={$qfKey}";
             }
             $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view', $urlParams));
             $values = $this->get('values');
             // get contact values.
             if (!empty($values)) {
                 $this->_values = $values;
             } else {
                 $params = array('id' => $this->_contactId, 'contact_id' => $this->_contactId, 'noRelationships' => TRUE, 'noNotes' => TRUE, 'noGroups' => TRUE);
                 $contact = CRM_Contact_BAO_Contact::retrieve($params, $this->_values, TRUE);
                 $this->set('values', $this->_values);
             }
         } else {
             CRM_Core_Error::statusBounce(ts('Could not get a contact_id and/or contact_type'));
         }
     }
     // parse street address, CRM-5450
     $this->_parseStreetAddress = $this->get('parseStreetAddress');
     if (!isset($this->_parseStreetAddress)) {
         $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options');
         $this->_parseStreetAddress = FALSE;
         if (CRM_Utils_Array::value('street_address', $addressOptions) && CRM_Utils_Array::value('street_address_parsing', $addressOptions)) {
             $this->_parseStreetAddress = TRUE;
         }
         $this->set('parseStreetAddress', $this->_parseStreetAddress);
     }
     $this->assign('parseStreetAddress', $this->_parseStreetAddress);
     $this->_editOptions = $this->get('contactEditOptions');
     if (CRM_Utils_System::isNull($this->_editOptions)) {
         $this->_editOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 0');
         $this->set('contactEditOptions', $this->_editOptions);
     }
     // build demographics only for Individual contact type
     if ($this->_contactType != 'Individual' && array_key_exists('Demographics', $this->_editOptions)) {
         unset($this->_editOptions['Demographics']);
     }
     // in update mode don't show notes
     if ($this->_contactId && array_key_exists('Notes', $this->_editOptions)) {
         unset($this->_editOptions['Notes']);
     }
     $this->assign('editOptions', $this->_editOptions);
     $this->assign('contactType', $this->_contactType);
     $this->assign('contactSubType', $this->_contactSubType);
     //build contact subtype form element, CRM-6864
     $buildContactSubType = TRUE;
     if ($this->_contactSubType && $this->_action & CRM_Core_Action::ADD) {
         $buildContactSubType = FALSE;
     }
     $this->assign('buildContactSubType', $buildContactSubType);
     // get the location blocks.
     $this->_blocks = $this->get('blocks');
     if (CRM_Utils_System::isNull($this->_blocks)) {
         $this->_blocks = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options', TRUE, NULL, FALSE, 'name', TRUE, 'AND v.filter = 1');
         $this->set('blocks', $this->_blocks);
     }
     $this->assign('blocks', $this->_blocks);
     // this is needed for custom data.
     $this->assign('entityID', $this->_contactId);
     // also keep the convention.
     $this->assign('contactId', $this->_contactId);
     // location blocks.
     CRM_Contact_Form_Location::preProcess($this);
     // execute preProcess dynamically by js else execute normal preProcess
     if (array_key_exists('CustomData', $this->_editOptions)) {
         if (CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject)) {
             CRM_Contact_Form_Edit_CustomData::preProcess($this);
         } else {
             $contactSubType = $this->_contactSubType;
             // need contact sub type to build related grouptree array during post process
             if (CRM_Utils_Array::value('contact_sub_type', $_POST)) {
                 $contactSubType = $_POST['contact_sub_type'];
             }
             //only custom data has preprocess hence directly call it
             CRM_Custom_Form_CustomData::preProcess($this, NULL, $contactSubType, 1, $this->_contactType, $this->_contactId);
         }
     }
 }
Exemplo n.º 19
0
 /** 
  * Heart of the viewing process. The runner gets all the meta data for 
  * the contact and calls the appropriate type of page to view. 
  * 
  * @return void 
  * @access public 
  * 
  */
 function preProcess()
 {
     $this->_id = CRM_Utils_Request::retrieve('id', $this);
     $this->assign('id', $this->_id);
     $this->_contactId = CRM_Utils_Request::retrieve('cid', $this, true);
     $this->assign('contactId', $this->_contactId);
     $this->_action = CRM_Utils_Request::retrieve('action', $this, false, 'browse');
     $this->assign('action', $this->_action);
     list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
     $this->assign('displayName', $displayName);
     $this->assign('contactImage', $contactImage);
     CRM_Utils_System::setTitle($contactImage . ' ' . $displayName);
 }
Exemplo n.º 20
0
 /**
  * Given a UF user object, make sure there is a contact
  * object for this user. If the user has new values, we need
  * to update the CRM DB with the new values
  *
  * @param Object  $user    the drupal user object
  * @param boolean $update  has the user object been edited
  * @param         $uf
  *
  * @return void
  * @access public
  * @static
  */
 static function synchronize(&$user, $update, $uf, $ctype, $isLogin = FALSE)
 {
     $config = CRM_Core_Config::singleton();
     $session = CRM_Core_Session::singleton();
     if (!is_object($session)) {
         CRM_Core_Error::fatal('wow, session is not an object?');
         return;
     }
     if ($config->userSystem->is_drupal) {
         $key = 'uid';
         $login = '******';
         $mail = 'mail';
     } elseif ($uf == 'Joomla') {
         $key = 'id';
         $login = '******';
         $mail = 'email';
         if (!isset($user->id) || !isset($user->email)) {
             $user = JFactory::getUser();
         }
     } elseif ($uf == 'WordPress') {
         $key = 'ID';
         $login = '******';
         $mail = 'user_email';
     } else {
         CRM_Core_Error::statusBounce(ts('Please set the user framework variable'));
     }
     // if the id of the object is zero (true for anon users in drupal)
     // have we already processed this user, if so early
     // return.
     $userID = $session->get('userID');
     $ufID = $session->get('ufID');
     if (!$update && $ufID == $user->{$key}) {
         return;
     }
     //check do we have logged in user.
     $isUserLoggedIn = CRM_Utils_System::isUserLoggedIn();
     // reset the session if we are a different user
     if ($ufID && $ufID != $user->{$key}) {
         $session->reset();
         //get logged in user ids, and set to session.
         if ($isUserLoggedIn) {
             $userIds = self::getUFValues();
             $session->set('ufID', CRM_Utils_Array::value('uf_id', $userIds, ''));
             $session->set('userID', CRM_Utils_Array::value('contact_id', $userIds, ''));
             $session->set('ufUniqID', CRM_Utils_Array::value('uf_name', $userIds, ''));
         }
     }
     // return early
     if ($user->{$key} == 0) {
         return;
     }
     if (!isset($uniqId) || !$uniqId) {
         $uniqId = $user->{$mail};
     }
     $ufmatch = self::synchronizeUFMatch($user, $user->{$key}, $uniqId, $uf, NULL, $ctype, $isLogin);
     if (!$ufmatch) {
         return;
     }
     //make sure we have session w/ consistent ids.
     $ufID = $ufmatch->uf_id;
     $userID = $ufmatch->contact_id;
     $ufUniqID = isset($ufmatch->user_unique_id) ? $ufmatch->user_unique_id : '';
     if ($isUserLoggedIn) {
         $loggedInUserUfID = CRM_Utils_System::getLoggedInUfID();
         //are we processing logged in user.
         if ($loggedInUserUfID && $loggedInUserUfID != $ufID) {
             $userIds = self::getUFValues($loggedInUserUfID);
             $ufID = CRM_Utils_Array::value('uf_id', $userIds, '');
             $userID = CRM_Utils_Array::value('contact_id', $userIds, '');
             $ufUniqID = CRM_Utils_Array::value('uf_name', $userIds, '');
         }
     }
     //set user ids to session.
     $session->set('ufID', $ufID);
     $session->set('userID', $userID);
     $session->set('ufUniqID', $ufUniqID);
     // add current contact to recently viewed
     if ($ufmatch->contact_id) {
         list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) = CRM_Contact_BAO_Contact::getDisplayAndImage($ufmatch->contact_id, TRUE, TRUE);
         $otherRecent = array('imageUrl' => $contactImageUrl, 'subtype' => $contactSubtype, 'editUrl' => CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$ufmatch->contact_id}"));
         CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$ufmatch->contact_id}"), $ufmatch->contact_id, $contactType, $ufmatch->contact_id, $displayName, $otherRecent);
     }
     if ($update) {
         // the only information we care about is uniqId, so lets check that
         if (!isset($ufmatch->user_unique_id) || $uniqId != $ufmatch->user_unique_id) {
             // uniqId has changed, so we need to update that everywhere
             $ufmatch->user_unique_id = $uniqId;
             $ufmatch->save();
         }
     }
 }
Exemplo n.º 21
0
 /**
  * Use values from $_GET if force is set to TRUE.
  *
  * Note that this means that GET over-rides POST. This was a historical decision & the reasoning is not explained.
  */
 public function fixFormValues()
 {
     if (!$this->_force) {
         return;
     }
     $status = CRM_Utils_Request::retrieve('status', 'String', CRM_Core_DAO::$_nullObject);
     if ($status) {
         $this->_formValues['contribution_status_id'] = array($status => 1);
         $this->_defaults['contribution_status_id'] = array($status => 1);
     }
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if ($cid) {
         $cid = CRM_Utils_Type::escape($cid, 'Integer');
         if ($cid > 0) {
             $this->_formValues['contact_id'] = $cid;
             // @todo - why do we retrieve these when they are not used?
             list($display, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($cid);
             $this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name');
             // also assign individual mode to the template
             $this->_single = TRUE;
         }
     }
     $lowDate = CRM_Utils_Request::retrieve('start', 'Timestamp', CRM_Core_DAO::$_nullObject);
     if ($lowDate) {
         $lowDate = CRM_Utils_Type::escape($lowDate, 'Timestamp');
         $date = CRM_Utils_Date::setDateDefaults($lowDate);
         $this->_formValues['contribution_date_low'] = $this->_defaults['contribution_date_low'] = $date[0];
     }
     $highDate = CRM_Utils_Request::retrieve('end', 'Timestamp', CRM_Core_DAO::$_nullObject);
     if ($highDate) {
         $highDate = CRM_Utils_Type::escape($highDate, 'Timestamp');
         $date = CRM_Utils_Date::setDateDefaults($highDate);
         $this->_formValues['contribution_date_high'] = $this->_defaults['contribution_date_high'] = $date[0];
     }
     if ($highDate || $lowDate) {
         //set the Choose Date Range value
         $this->_formValues['contribution_date_relative'] = 0;
     }
     $this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
     $test = CRM_Utils_Request::retrieve('test', 'Boolean', CRM_Core_DAO::$_nullObject);
     if (isset($test)) {
         $test = CRM_Utils_Type::escape($test, 'Boolean');
         $this->_formValues['contribution_test'] = $test;
     }
     //Recurring id
     $recur = CRM_Utils_Request::retrieve('recur', 'Positive', $this, FALSE);
     if ($recur) {
         $this->_formValues['contribution_recur_id'] = $recur;
         $this->_formValues['contribution_recurring'] = 1;
     }
     //check for contribution page id.
     $contribPageId = CRM_Utils_Request::retrieve('pid', 'Positive', $this);
     if ($contribPageId) {
         $this->_formValues['contribution_page_id'] = $contribPageId;
     }
     //give values to default.
     $this->_defaults = $this->_formValues;
 }
Exemplo n.º 22
0
 /**
  * pre processing work done here.
  *
  * gets session variables for table name, id of entity in table, type of entity and stores them.
  *
  * @param
  * @return void
  *
  * @access public
  *
  */
 function preProcess()
 {
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', false);
     if ($this->_cdType) {
         $this->assign('cdType', true);
         return CRM_Custom_Form_CustomData::preProcess($this);
     }
     $this->_groupID = CRM_Utils_Request::retrieve('groupId', 'Positive', $this, true);
     $this->_tableID = CRM_Utils_Request::retrieve('tableId', 'Positive', $this, true);
     require_once "CRM/Contact/BAO/Contact.php";
     $this->_contactType = CRM_Contact_BAO_Contact::getContactType($this->_tableID);
     $this->_contactSubType = CRM_Contact_BAO_Contact::getContactSubType($this->_tableID);
     $this->assign('contact_type', $this->_contactType);
     $this->assign('contact_subtype', $this->_contactSubType);
     list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_tableID);
     CRM_Utils_System::setTitle($displayName, $contactImage . ' ' . $displayName);
     // when custom data is included in this page
     if (CRM_Utils_Array::value("hidden_custom", $_POST)) {
         for ($i; $i <= $_POST['hidden_custom_group_count'][$this->_groupID]; $i++) {
             CRM_Custom_Form_CustomData::preProcess($this, null, null, $i);
             CRM_Custom_Form_CustomData::buildQuickForm($this);
             CRM_Custom_Form_CustomData::setDefaultValues($this);
         }
     }
 }
Exemplo n.º 23
0
 function fixFormValues()
 {
     if (!$this->_force) {
         return;
     }
     $caseStatus = CRM_Utils_Request::retrieve('status', 'Positive', CRM_Core_DAO::$_nullObject);
     if ($caseStatus) {
         $this->_formValues['case_status_id'] = $caseStatus;
         $this->_defaults['case_status_id'] = $caseStatus;
     }
     $caseType = CRM_Utils_Request::retrieve('type', 'Positive', CRM_Core_DAO::$_nullObject);
     if ($caseType) {
         $this->_formValues['case_type_id'][$caseType] = 1;
         $this->_defaults['case_type_id'][$caseType] = 1;
     }
     $caseFromDate = CRM_Utils_Request::retrieve('pstart', 'Date', CRM_Core_DAO::$_nullObject);
     if ($caseFromDate) {
         $date = CRM_Utils_Date::unformat($caseFromDate, '');
         $this->_formValues['case_start_date_low'] = $date;
         $this->_defaults['case_start_date_low'] = $date;
     }
     $caseToDate = CRM_Utils_Request::retrieve('pend', 'Date', CRM_Core_DAO::$_nullObject);
     if ($caseToDate) {
         $date = CRM_Utils_Date::unformat($caseToDate, '');
         $this->_formValues['case_start_date_high'] = $date;
         $this->_defaults['case_start_date_high'] = $date;
     }
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if ($cid) {
         $cid = CRM_Utils_Type::escape($cid, 'Integer');
         if ($cid > 0) {
             require_once 'CRM/Contact/BAO/Contact.php';
             $this->_formValues['contact_id'] = $cid;
             list($display, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($cid);
             $this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name');
             // also assign individual mode to the template
             $this->_single = true;
         }
     } else {
         $session =& CRM_Core_Session::singleton();
         if (!CRM_Utils_Request::retrieve('all', 'Positive', $session)) {
             $this->_formValues['case_mycases'] = 0;
             $this->_formValues['case_owner'] = 0;
             $this->_defaults['case_owner'] = 0;
         } else {
             $this->_formValues['case_owner'] = 1;
             $this->_defaults['case_owner'] = 1;
         }
         $caseOwner = CRM_Utils_Request::retrieve('case_owner', 'Boolean', CRM_Core_DAO::$_nullObject);
         if ($caseOwner) {
             $this->_formValues['case_owner'] = 0;
             $this->_defaults['case_owner'] = 0;
         }
     }
 }
Exemplo n.º 24
0
 function preProcess()
 {
     if (!$this->_contactId) {
         CRM_Core_Error::fatal(ts('We could not find a contact id.'));
     }
     list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($this->_contactId);
     $this->set('displayName', $displayName);
     $this->set('contactImage', $contactImage);
     CRM_Utils_System::setTitle(ts('Dashboard - %1', array(1 => $displayName)));
     $this->assign('recentlyViewed', false);
 }
Exemplo n.º 25
0
 /**
  * Browse all custom data groups.
  *  
  * 
  * @return void
  * @access public
  * @static
  */
 function browse($action = null)
 {
     require_once 'CRM/Contact/BAO/GroupNesting.php';
     $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
     if ($this->_sortByCharacter == 1 || !empty($_POST)) {
         $this->_sortByCharacter = '';
     }
     require_once 'CRM/Contribute/PseudoConstant.php';
     $status = CRM_Contribute_PseudoConstant::pcpstatus();
     $contribution_page = CRM_Contribute_PseudoConstant::contributionPage();
     $pcpSummary = $params = array();
     $whereClause = null;
     if (!empty($_POST)) {
         if ($_POST['status_id'] != 0) {
             $whereClause = ' AND cp.status_id = %1';
             $params['1'] = array($_POST['status_id'], 'Integer');
         }
         if ($_POST['contibution_page_id'] != 0) {
             $whereClause .= ' AND cp.contribution_page_id = %2';
             $params['2'] = array($_POST['contibution_page_id'], 'Integer');
         }
         if ($_POST['status_id'] != 0 || $_POST['contibution_page_id'] != 0) {
             $this->set('whereClause', $whereClause);
             $this->set('params', $params);
         } else {
             $this->set('whereClause', null);
             $this->set('params', null);
         }
     }
     $approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name');
     //check for delete CRM-4418
     require_once 'CRM/Core/Permission.php';
     $allowToDelete = CRM_Core_Permission::check('delete in CiviContribute');
     $params = $this->get('params') ? $this->get('params') : array();
     $title = ' AND cp.title LIKE %3';
     $params['3'] = array($this->_sortByCharacter . '%', 'String');
     $query = "\n        SELECT cp.id as id, contact_id , status_id, cp.title as title, contribution_page_id, start_date, end_date, cp.is_active as active\n        FROM civicrm_pcp cp, civicrm_contribution_page cpp\n        WHERE cp.contribution_page_id = cpp.id {$title}" . $this->get('whereClause') . " ORDER BY status_id";
     $dao = CRM_Core_DAO::executeQuery($query, $params, true, 'CRM_Contribute_DAO_PCP');
     while ($dao->fetch()) {
         $pcpSummary[$dao->id] = array();
         $action = array_sum(array_keys($this->links()));
         CRM_Core_DAO::storeValues($dao, $pcpSummary[$dao->id]);
         require_once 'CRM/Contact/BAO/Contact.php';
         $contact = CRM_Contact_BAO_Contact::getDisplayAndImage($dao->contact_id);
         $class = '';
         if ($dao->status_id != $approvedId || $dao->active != 1) {
             $class = 'disabled';
         }
         switch ($dao->status_id) {
             case 2:
                 $action -= CRM_Core_Action::RENEW;
                 break;
             case 3:
                 $action -= CRM_Core_Action::REVERT;
                 break;
         }
         if (!$allowToDelete) {
             $action -= CRM_Core_Action::DELETE;
         }
         $pcpSummary[$dao->id]['id'] = $dao->id;
         $pcpSummary[$dao->id]['start_date'] = $dao->start_date;
         $pcpSummary[$dao->id]['end_date'] = $dao->end_date;
         $pcpSummary[$dao->id]['supporter'] = $contact['0'];
         $pcpSummary[$dao->id]['supporter_id'] = $dao->contact_id;
         $pcpSummary[$dao->id]['status_id'] = $status[$dao->status_id];
         $pcpSummary[$dao->id]['contribution_page_id'] = $dao->contribution_page_id;
         $pcpSummary[$dao->id]['contribution_page_title'] = $contribution_page[$dao->contribution_page_id];
         $pcpSummary[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id));
         $pcpSummary[$dao->id]['class'] = $class;
     }
     $this->search();
     $this->pagerAToZ($this->get('whereClause'), $params);
     if ($pcpSummary) {
         $this->assign('rows', $pcpSummary);
     }
     // Let template know if user has run a search or not
     if ($this->get('whereClause')) {
         $this->assign('isSearch', 1);
     } else {
         $this->assign('isSearch', 0);
     }
 }
Exemplo n.º 26
0
 function fixFormValues()
 {
     // if this search has been forced
     // then see if there are any get values, and if so over-ride the post values
     // note that this means that GET over-rides POST :)
     if (!$this->_force) {
         return;
     }
     $status = CRM_Utils_Request::retrieve('status', 'String', CRM_Core_DAO::$_nullObject);
     if ($status) {
         $this->_formValues['contribution_status_id'] = array($status => 1);
         $this->_defaults['contribution_status_id'] = array($status => 1);
     }
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if ($cid) {
         $cid = CRM_Utils_Type::escape($cid, 'Integer');
         if ($cid > 0) {
             require_once 'CRM/Contact/BAO/Contact.php';
             $this->_formValues['contact_id'] = $cid;
             list($display, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($cid);
             $this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name');
             // also assign individual mode to the template
             $this->_single = true;
         }
     }
     $lowDate = CRM_Utils_Request::retrieve('start', 'Timestamp', CRM_Core_DAO::$_nullObject);
     if ($lowDate) {
         $lowDate = CRM_Utils_Type::escape($lowDate, 'Timestamp');
         $date = CRM_Utils_Date::setDateDefaults($lowDate);
         $this->_formValues['contribution_date_low'] = $this->_defaults['contribution_date_low'] = $date[0] . ' ' . $date[1];
     }
     $highDate = CRM_Utils_Request::retrieve('end', 'Timestamp', CRM_Core_DAO::$_nullObject);
     if ($highDate) {
         $highDate = CRM_Utils_Type::escape($highDate, 'Timestamp');
         $date = CRM_Utils_Date::setDateDefaults($highDate);
         $this->_formValues['contribution_date_high'] = $this->_defaults['contribution_date_high'] = $date[0] . ' 23:59:59';
     }
     $this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
     $test = CRM_Utils_Request::retrieve('test', 'Boolean', CRM_Core_DAO::$_nullObject);
     if (isset($test)) {
         $test = CRM_Utils_Type::escape($test, 'Boolean');
         $this->_formValues['contribution_test'] = $test;
     }
     //Recurring id
     $recur = CRM_Utils_Request::retrieve('recur', 'Positive', $this, false);
     if ($recur) {
         $this->_formValues['contribution_recur_id'] = $recur;
         $this->_formValues['contribution_recurring'] = 1;
     }
 }
Exemplo n.º 27
0
 function fixFormValues()
 {
     // if this search has been forced
     // then see if there are any get values, and if so over-ride the post values
     // note that this means that GET over-rides POST :)
     if (!$this->_force) {
         return;
     }
     $status = CRM_Utils_Request::retrieve('status', 'String', CRM_Core_DAO::$_nullObject);
     if ($status) {
         $status = explode(',', $status);
         $tempStatus = array();
         foreach ($status as $value) {
             $tempStatus[$value] = 1;
         }
         $this->_formValues['member_status_id'] = $tempStatus;
         $this->_defaults['member_status_id'] = $tempStatus;
     }
     $membershipType = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject);
     if ($membershipType) {
         $this->_formValues['member_membership_type_id'] = array($membershipType => 1);
         $this->_defaults['member_membership_type_id'] = array($membershipType => 1);
     }
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject);
     if ($cid) {
         $cid = CRM_Utils_Type::escape($cid, 'Integer');
         if ($cid > 0) {
             $this->_formValues['contact_id'] = $cid;
             list($display, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($cid);
             $this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name');
             // also assign individual mode to the template
             $this->_single = TRUE;
         }
     }
     $fromDate = CRM_Utils_Request::retrieve('start', 'Date', CRM_Core_DAO::$_nullObject);
     if ($fromDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($fromDate);
         $this->_formValues['member_start_date_low'] = $this->_defaults['member_start_date_low'] = $date;
     }
     $toDate = CRM_Utils_Request::retrieve('end', 'Date', CRM_Core_DAO::$_nullObject);
     if ($toDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($toDate);
         $this->_formValues['member_start_date_high'] = $this->_defaults['member_start_date_high'] = $date;
     }
     $joinDate = CRM_Utils_Request::retrieve('join', 'Date', CRM_Core_DAO::$_nullObject);
     if ($joinDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($joinDate);
         $this->_formValues['member_join_date_low'] = $this->_defaults['member_join_date_low'] = $date;
     }
     $joinEndDate = CRM_Utils_Request::retrieve('joinEnd', 'Date', CRM_Core_DAO::$_nullObject);
     if ($joinEndDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($joinEndDate);
         $this->_formValues['member_join_date_high'] = $this->_defaults['member_join_date_high'] = $date;
     }
     $this->_limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this);
     //LCD also allow restrictions to membership owner via GET
     $owner = CRM_Utils_Request::retrieve('owner', 'String', CRM_Core_DAO::$_nullObject);
     if ($owner) {
         $this->_formValues['member_is_primary'] = $this->_defaults['member_is_primary'] = 2;
     }
 }
Exemplo n.º 28
0
 /**
  * Browse all custom data groups.
  *
  *
  * @param null $action
  *
  * @return void
  * @access public
  * @static
  */
 function browse($action = NULL)
 {
     $this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter', 'String', $this);
     if ($this->_sortByCharacter == 1 || !empty($_POST)) {
         $this->_sortByCharacter = '';
     }
     $status = CRM_PCP_BAO_PCP::buildOptions('status_id', 'create');
     $pcpSummary = $params = array();
     $whereClause = NULL;
     if (!empty($_POST) || !empty($_GET['page_type'])) {
         if (!empty($_POST['status_id'])) {
             $whereClause = ' AND cp.status_id = %1';
             $params['1'] = array($_POST['status_id'], 'Integer');
         }
         if (!empty($_POST['page_type'])) {
             $whereClause .= ' AND cp.page_type = %2';
             $params['2'] = array($_POST['page_type'], 'String');
         } elseif (!empty($_GET['page_type'])) {
             $whereClause .= ' AND cp.page_type = %2';
             $params['2'] = array($_GET['page_type'], 'String');
         }
         if (!empty($_POST['page_id'])) {
             $whereClause .= ' AND cp.page_id = %4 AND cp.page_type = "contribute"';
             $params['4'] = array($_POST['page_id'], 'Integer');
         }
         if (!empty($_POST['event_id'])) {
             $whereClause .= ' AND cp.page_id = %5 AND cp.page_type = "event"';
             $params['5'] = array($_POST['event_id'], 'Integer');
         }
         if ($whereClause) {
             $this->set('whereClause', $whereClause);
             $this->set('params', $params);
         } else {
             $this->set('whereClause', NULL);
             $this->set('params', NULL);
         }
     }
     $approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name');
     //check for delete CRM-4418
     $allowToDelete = CRM_Core_Permission::check('delete in CiviContribute');
     // get all contribution pages
     $query = "SELECT id, title, start_date, end_date FROM civicrm_contribution_page WHERE (1)";
     $cpages = CRM_Core_DAO::executeQuery($query);
     while ($cpages->fetch()) {
         $pages['contribute'][$cpages->id]['id'] = $cpages->id;
         $pages['contribute'][$cpages->id]['title'] = $cpages->title;
         $pages['contribute'][$cpages->id]['start_date'] = $cpages->start_date;
         $pages['contribute'][$cpages->id]['end_date'] = $cpages->end_date;
     }
     // get all event pages. pcp campaign start and end dates for event related pcp's use the online registration start and end dates,
     // altho if target is contribution page this might not be correct. fixme? dgg
     $query = "SELECT id, title, start_date, end_date, registration_start_date, registration_end_date\n                  FROM civicrm_event\n                  WHERE is_template IS NULL OR is_template != 1";
     $epages = CRM_Core_DAO::executeQuery($query);
     while ($epages->fetch()) {
         $pages['event'][$epages->id]['id'] = $epages->id;
         $pages['event'][$epages->id]['title'] = $epages->title;
         $pages['event'][$epages->id]['start_date'] = $epages->registration_start_date;
         $pages['event'][$epages->id]['end_date'] = $epages->registration_end_date;
     }
     $params = $this->get('params') ? $this->get('params') : array();
     $title = '1';
     if ($this->_sortByCharacter !== NULL) {
         $clauses[] = "cp.title LIKE '" . strtolower(CRM_Core_DAO::escapeWildCardString($this->_sortByCharacter)) . "%'";
     }
     $query = "\n        SELECT cp.id, cp.contact_id , cp.status_id, cp.title, cp.is_active, cp.page_type, cp.page_id\n        FROM civicrm_pcp cp\n        WHERE {$title}" . $this->get('whereClause') . " ORDER BY cp.status_id";
     $pcp = CRM_Core_DAO::executeQuery($query, $params);
     while ($pcp->fetch()) {
         $action = array_sum(array_keys($this->links()));
         $contact = CRM_Contact_BAO_Contact::getDisplayAndImage($pcp->contact_id);
         $class = '';
         if ($pcp->status_id != $approvedId || $pcp->is_active != 1) {
             $class = 'disabled';
         }
         switch ($pcp->status_id) {
             case 2:
                 $action -= CRM_Core_Action::RENEW;
                 break;
             case 3:
                 $action -= CRM_Core_Action::REVERT;
                 break;
         }
         switch ($pcp->is_active) {
             case 1:
                 $action -= CRM_Core_Action::ENABLE;
                 break;
             case 0:
                 $action -= CRM_Core_Action::DISABLE;
                 break;
         }
         if (!$allowToDelete) {
             $action -= CRM_Core_Action::DELETE;
         }
         $page_type = $pcp->page_type;
         $page_id = (int) $pcp->page_id;
         if ($pages[$page_type][$page_id]['title'] == '' || $pages[$page_type][$page_id]['title'] == NULL) {
             $title = '(no title found for ' . $page_type . ' id ' . $page_id . ')';
         } else {
             $title = $pages[$page_type][$page_id]['title'];
         }
         if ($pcp->page_type == 'contribute') {
             $pageUrl = CRM_Utils_System::url('civicrm/' . $page_type . '/transact', 'reset=1&id=' . $pcp->page_id);
         } else {
             $pageUrl = CRM_Utils_System::url('civicrm/' . $page_type . '/register', 'reset=1&id=' . $pcp->page_id);
         }
         $pcpSummary[$pcp->id] = array('id' => $pcp->id, 'start_date' => $pages[$page_type][$page_id]['start_date'], 'end_date' => $pages[$page_type][$page_id]['end_date'], 'supporter' => $contact['0'], 'supporter_id' => $pcp->contact_id, 'status_id' => $status[$pcp->status_id], 'page_id' => $page_id, 'page_title' => $title, 'page_url' => $pageUrl, 'page_type' => $page_type, 'action' => CRM_Core_Action::formLink(self::links(), $action, array('id' => $pcp->id), ts('more'), FALSE, 'contributionpage.pcp.list', 'PCP', $pcp->id), 'title' => $pcp->title, 'class' => $class);
     }
     $this->search();
     $this->pagerAToZ($this->get('whereClause'), $params);
     $this->assign('rows', $pcpSummary);
     // Let template know if user has run a search or not
     if ($this->get('whereClause')) {
         $this->assign('isSearch', 1);
     } else {
         $this->assign('isSearch', 0);
     }
 }
Exemplo n.º 29
0
 /**
  * Get meta details of the contact.
  *
  * @param int $contactId
  *
  * @return array
  *   contact fields in fixed order
  */
 public static function getContactDetails($contactId)
 {
     return list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) = CRM_Contact_BAO_Contact::getDisplayAndImage($contactId, TRUE, TRUE);
 }
Exemplo n.º 30
0
 public function fixFormValues()
 {
     if (!$this->_force) {
         return;
     }
     // set pledge payment related fields
     $status = CRM_Utils_Request::retrieve('status', 'String', CRM_Core_DAO::$_nullObject);
     if ($status) {
         $this->_formValues['pledge_payment_status_id'] = array($status => 1);
         $this->_defaults['pledge_payment_status_id'] = array($status => 1);
     }
     $fromDate = CRM_Utils_Request::retrieve('start', 'Date', CRM_Core_DAO::$_nullObject);
     if ($fromDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($fromDate);
         $this->_formValues['pledge_payment_date_low'] = $date;
         $this->_defaults['pledge_payment_date_low'] = $date;
     }
     $toDate = CRM_Utils_Request::retrieve('end', 'Date', CRM_Core_DAO::$_nullObject);
     if ($toDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($toDate);
         $this->_formValues['pledge_payment_date_high'] = $date;
         $this->_defaults['pledge_payment_date_high'] = $date;
     }
     // set pledge related fields
     $pledgeStatus = CRM_Utils_Request::retrieve('pstatus', 'String', CRM_Core_DAO::$_nullObject);
     if ($pledgeStatus) {
         $statusValues = CRM_Contribute_PseudoConstant::contributionStatus();
         // Remove status values that are only used for recurring contributions for now (Failed).
         unset($statusValues['4']);
         // we need set all statuses except Cancelled
         unset($statusValues[$pledgeStatus]);
         $statuses = array();
         foreach ($statusValues as $statusId => $value) {
             $statuses[$statusId] = 1;
         }
         $this->_formValues['pledge_status_id'] = $statuses;
         $this->_defaults['pledge_status_id'] = $statuses;
     }
     $pledgeFromDate = CRM_Utils_Request::retrieve('pstart', 'Date', CRM_Core_DAO::$_nullObject);
     if ($pledgeFromDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($pledgeFromDate);
         $this->_formValues['pledge_create_date_low'] = $this->_defaults['pledge_create_date_low'] = $date;
     }
     $pledgeToDate = CRM_Utils_Request::retrieve('pend', 'Date', CRM_Core_DAO::$_nullObject);
     if ($pledgeToDate) {
         list($date) = CRM_Utils_Date::setDateDefaults($pledgeToDate);
         $this->_formValues['pledge_create_date_high'] = $this->_defaults['pledge_create_date_high'] = $date;
     }
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     if ($cid) {
         $cid = CRM_Utils_Type::escape($cid, 'Integer');
         if ($cid > 0) {
             $this->_formValues['contact_id'] = $cid;
             list($display, $image) = CRM_Contact_BAO_Contact::getDisplayAndImage($cid);
             $this->_defaults['sort_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'sort_name');
             // also assign individual mode to the template
             $this->_single = TRUE;
         }
     }
 }