예제 #1
0
 /**
  * Create a new HRJobDetails based on array-data
  *
  * @param array $params key-value pairs
  * @return CRM_HRJob_DAO_HRJobDetails|NULL
  *
  */
 public static function create($params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     $previousDetailsRevisionId = null;
     if ($hook == 'create') {
         $previousRevisionResult = civicrm_api3('HRJobContractRevision', 'getcurrentrevision', array('sequential' => 1, 'jobcontract_id' => $params['jobcontract_id']));
         if (!empty($previousRevisionResult['values']['details_revision_id'])) {
             $previousDetailsRevisionId = $previousRevisionResult['values']['details_revision_id'];
         }
     }
     $instance = parent::create($params);
     // setting 'effective_date' if it's not set:
     $revision = civicrm_api3('HRJobContractRevision', 'get', array('sequential' => 1, 'jobcontract_id' => $params['jobcontract_id'], 'id' => $instance->jobcontract_revision_id));
     if (!empty($revision['values'][0])) {
         $revisionData = array_shift($revision['values']);
         if (!$revisionData['effective_date']) {
             civicrm_api3('HRJobContractRevision', 'create', array('id' => $revisionData['id'], 'effective_date' => $instance->period_start_date));
         }
     }
     $revisionResult = civicrm_api3('HRJobContractRevision', 'get', array('sequential' => 1, 'id' => $instance->jobcontract_revision_id));
     $revision = CRM_Utils_Array::first($revisionResult['values']);
     $duplicate = CRM_Utils_Array::value('action', $params, $hook);
     if ($hook == 'create' && empty($revision['role_revision_id']) && $duplicate != 'duplicate' && empty($params['import'])) {
         //civicrm_api3('HRJobRole', 'create', array('jobcontract_id' => $revision['jobcontract_id'],'title' => $instance->title, 'location'=> $instance->location, 'percent_pay_role' => 100, 'jobcontract_revision_id' => $instance->jobcontract_revision_id));
         CRM_Hrjobcontract_BAO_HRJobRole::create(array('jobcontract_id' => $revision['jobcontract_id'], 'title' => $instance->title, 'location' => $instance->location, 'percent_pay_role' => 100, 'jobcontract_revision_id' => $instance->jobcontract_revision_id));
     }
     if ($previousDetailsRevisionId) {
         CRM_Core_BAO_File::copyEntityFile('civicrm_hrjobcontract_details', $previousDetailsRevisionId, 'civicrm_hrjobcontract_details', $revision['details_revision_id']);
     }
     $contract = new CRM_Hrjobcontract_DAO_HRJobContract();
     $contract->id = $revision['jobcontract_id'];
     $contract->find(true);
     CRM_Hrjobcontract_JobContractDates::setDates($contract->contact_id, $revision['jobcontract_id'], $instance->period_start_date, $instance->period_end_date);
     return $instance;
 }
 public function run()
 {
     $entityID = CRM_Utils_Request::retrieve('entityID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
     $fileID = CRM_Utils_Request::retrieve('fileID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
     $file = false;
     if (is_numeric($fileID)) {
         $file = civicrm_api3('File', 'getsingle', array('id' => $fileID));
     }
     try {
         CRM_Core_BAO_File::deleteAttachment();
     } catch (Exception $e) {
         return null;
     }
     //Do the backend-service delete
     if ($file && !empty($file['description'])) {
         $details = json_decode($file['description']);
         if ($details && property_exists($details, "source") && $details->source == "securefiles") {
             //Check extension level permissions
             CRM_Securefiles_Permission::checkFilePerms(CRM_Core_Action::DELETE, $fileID, $entityID);
             $backendService = CRM_Securefiles_Backend::getBackendService();
             if ($backendService) {
                 //Check backend service permissions
                 if ($backendService->checkPermissions(CRM_Core_Action::DELETE, $fileID, $entityID) !== false) {
                     $backendService->deleteFile($file['uri'], $entityID);
                 }
             }
         }
     }
 }
예제 #3
0
 function run()
 {
     require_once 'CRM/Utils/Request.php';
     require_once 'CRM/Core/DAO.php';
     $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, true);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false);
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
     $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     require_once 'CRM/Core/BAO/File.php';
     list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, null, $quest);
     if (!$path) {
         CRM_Core_Error::statusBounce('Could not retrieve the file');
     }
     $buffer = file_get_contents($path);
     if (!$buffer) {
         CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
     }
     if ($action & CRM_Core_Action::DELETE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
             CRM_Core_BAO_File::delete($id, $eid, $fid);
             CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
             $session = CRM_Core_Session::singleton();
             $toUrl = $session->popUserContext();
             CRM_Utils_System::redirect($toUrl);
         } else {
             $wrapper = new CRM_Utils_Wrapper();
             return $wrapper->run('CRM_Custom_Form_DeleteFile', ts('Domain Information Page'), null);
         }
     } else {
         require_once 'CRM/Utils/File.php';
         CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
     }
 }
예제 #4
0
 /**
  * Constructor.
  *
  * @param null $path
  *   The class Path of the form being implemented
  * @param bool $title
  * @param string $mode
  * @param bool $imageUpload
  * @param bool $addSequence
  *   Should we add a unique sequence number to the end of the key.
  * @param bool $ignoreKey
  *   Should we not set a qfKey for this controller (for standalone forms).
  * @param bool $attachUpload
  *
  * @return \CRM_Core_Controller_Simple
  */
 public function __construct($path, $title, $mode = NULL, $imageUpload = FALSE, $addSequence = FALSE, $ignoreKey = FALSE, $attachUpload = FALSE)
 {
     // by definition a single page is modal :). We use the form name as the scope for this controller
     parent::__construct($title, TRUE, $mode, $path, $addSequence, $ignoreKey);
     $this->_stateMachine = new CRM_Core_StateMachine($this);
     $params = array($path => NULL);
     $savedAction = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, NULL);
     if (!empty($savedAction) && $savedAction != $mode) {
         $mode = $savedAction;
     }
     $this->_stateMachine->addSequentialPages($params, $mode);
     $this->addPages($this->_stateMachine, $mode);
     //changes for custom data type File
     $uploadNames = $this->get('uploadNames');
     $config = CRM_Core_Config::singleton();
     if (is_array($uploadNames) && !empty($uploadNames)) {
         $uploadArray = $uploadNames;
         $this->addActions($config->customFileUploadDir, $uploadArray);
         $this->set('uploadNames', NULL);
     } else {
         // always allow a single upload file with same name
         if ($attachUpload) {
             $this->addActions($config->uploadDir, CRM_Core_BAO_File::uploadNames());
         } elseif ($imageUpload) {
             $this->addActions($config->imageUploadDir, array('uploadFile'));
         } else {
             $this->addActions();
         }
     }
 }
예제 #5
0
파일: Simple.php 프로젝트: ksecor/civicrm
 /**
  * constructor
  *
  * @param string  path        the class Path of the form being implemented
  * @param string  title       the descriptive name for the page
  * @param int     mode        the mode that the form will operate on
  * @param boolean addSequence should we add a unique sequence number to the end of the key
  * @param boolean ignoreKey    should we not set a qfKey for this controller (for standalone forms)
  *
  * @return object
  * @access public
  */
 function __construct($path, $title, $mode = null, $imageUpload = false, $addSequence = false, $ignoreKey = false, $attachUpload = false)
 {
     // by definition a single page is modal :). We use the form name as the scope for this controller
     parent::__construct($title, true, $mode, $path, $addSequence, $ignoreKey);
     $this->_stateMachine =& new CRM_Core_StateMachine($this);
     $params = array($path => null);
     $this->_stateMachine->addSequentialPages($params, $mode);
     $this->addPages($this->_stateMachine, $mode);
     //changes for custom data type File
     $uploadNames = $this->get('uploadNames');
     $config =& CRM_Core_Config::singleton();
     if (is_array($uploadNames) && !empty($uploadNames)) {
         $uploadArray = $uploadNames;
         $this->addActions($config->customFileUploadDir, $uploadArray);
         $this->set('uploadNames', null);
     } else {
         // always allow a single upload file with same name
         if ($attachUpload) {
             require_once 'CRM/Core/BAO/File.php';
             $this->addActions($config->uploadDir, CRM_Core_BAO_File::uploadNames());
         } else {
             if ($imageUpload) {
                 $this->addActions($config->imageUploadDir, array('uploadFile'));
             } else {
                 $this->addActions();
             }
         }
     }
 }
예제 #6
0
파일: Test.php 프로젝트: bhirsch/voipdev
 public function buildQuickForm()
 {
     $session =& CRM_Core_Session::singleton();
     $this->add('text', 'test_email', ts('Send to This Address'));
     $defaults['test_email'] = $session->get('ufUniqID');
     $qfKey = $this->get('qfKey');
     $this->add('select', 'test_group', ts('Send to This Group'), array('' => ts('- none -')) + CRM_Core_PseudoConstant::group('Mailing'));
     $this->setDefaults($defaults);
     $this->add('submit', 'sendtest', ts('Send a Test Mailing'));
     //FIXME : currently we are hiding save an continue later when
     //search base mailing, we should handle it when we fix CRM-3876
     $buttons = array(array('type' => 'back', 'name' => '<< Previous'), array('type' => 'next', 'name' => ts('Next >>'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
     if ($this->get('context') == 'search' && $this->get('ssID')) {
         $buttons = array(array('type' => 'back', 'name' => '<< Previous'), array('type' => 'next', 'name' => ts('Next >>'), 'spacing' => '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;', 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel')));
     }
     $this->addButtons($buttons);
     $mailingID = $this->get('mailing_id');
     $textFile = $this->get('textFile');
     $htmlFile = $this->get('htmlFile');
     $subject = $this->get('subject');
     $this->assign('subject', $subject);
     $this->addFormRule(array('CRM_Mailing_Form_Test', 'testMail'), $this);
     $preview = array();
     if ($textFile) {
         $preview['text_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=text&qfKey={$qfKey}");
     }
     if ($htmlFile) {
         $preview['html_link'] = CRM_Utils_System::url('civicrm/mailing/preview', "type=html&qfKey={$qfKey}");
     }
     require_once 'CRM/Core/BAO/File.php';
     $preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $mailingID);
     $this->assign('preview', $preview);
 }
예제 #7
0
 public function run()
 {
     $eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, TRUE);
     $fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE);
     $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
     $action = CRM_Utils_Request::retrieve('action', 'String', $this);
     list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, NULL, $quest);
     if (!$path) {
         CRM_Core_Error::statusBounce('Could not retrieve the file');
     }
     $buffer = file_get_contents($path);
     if (!$buffer) {
         CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
     }
     if ($action & CRM_Core_Action::DELETE) {
         if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
             CRM_Core_BAO_File::deleteFileReferences($id, $eid, $fid);
             CRM_Core_Session::setStatus(ts('The attached file has been deleted.'), ts('Complete'), 'success');
             $session = CRM_Core_Session::singleton();
             $toUrl = $session->popUserContext();
             CRM_Utils_System::redirect($toUrl);
         }
     } else {
         CRM_Utils_System::download(CRM_Utils_File::cleanFileName(basename($path)), $mimeType, $buffer);
     }
 }
 /**
  * Process the form when submitted
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     CRM_Core_BAO_File::delete($this->_id, $this->_eid);
     CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
     $session = CRM_Core_Session::singleton();
     $toUrl = $session->popUserContext();
     CRM_Utils_System::redirect($toUrl);
 }
예제 #9
0
파일: Files.php 프로젝트: JoeMurray/civihr
 function fileDelete()
 {
     // delete file
     $postParams = $_POST;
     $fileId = $postParams['fileID'];
     CRM_Core_BAO_File::deleteEntityFile($postParams['entityTable'], $postParams['entityID'], $fileTypeID = NULL, $fileId);
     CRM_Utils_System::civiExit();
 }
예제 #10
0
 /**
  * Fetch the template text/html messages
  */
 public static function template()
 {
     $templateId = CRM_Utils_Type::escape($_POST['tid'], 'Integer');
     $messageTemplate = new CRM_Core_DAO_MessageTemplate();
     $messageTemplate->id = $templateId;
     $messageTemplate->selectAdd();
     $messageTemplate->selectAdd('msg_text, msg_html, msg_subject, pdf_format_id');
     $messageTemplate->find(TRUE);
     $messages = array('subject' => $messageTemplate->msg_subject, 'msg_text' => $messageTemplate->msg_text, 'msg_html' => $messageTemplate->msg_html, 'pdf_format_id' => $messageTemplate->pdf_format_id);
     $documentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_msg_template', $templateId);
     foreach ((array) $documentInfo as $info) {
         list($messages['document_body']) = CRM_Utils_PDF_Document::docReader($info['fullPath'], $info['mime_type']);
     }
     CRM_Utils_JSON::output($messages);
 }
예제 #11
0
파일: Preview.php 프로젝트: ksecor/civicrm
 /** 
  * run this page (figure out the action needed and perform it).
  * 
  * @return void
  */
 function run()
 {
     require_once 'CRM/Mailing/BAO/Mailing.php';
     $session =& CRM_Core_Session::singleton();
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, false, 'text');
     $type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject, false, 'text');
     $options = array();
     $session->getVars($options, "CRM_Mailing_Controller_Send_{$qfKey}");
     //get the options if control come from search context, CRM-3711
     if (empty($options)) {
         $session->getVars($options, "CRM_Contact_Controller_Search_{$qfKey}");
     }
     // FIXME: the below and CRM_Mailing_Form_Test::testMail()
     // should be refactored
     $fromEmail = null;
     $mailing =& new CRM_Mailing_BAO_Mailing();
     if (!empty($options)) {
         $mailing->id = $options['mailing_id'];
         $fromEmail = $options['from_email'];
     }
     $mailing->find(true);
     CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
     if (defined('CIVICRM_MAIL_SMARTY')) {
         require_once 'CRM/Core/Smarty/resources/String.php';
         civicrm_smarty_register_string_resource();
     }
     // get and format attachments
     require_once 'CRM/Core/BAO/File.php';
     $attachments =& CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
     //get details of contact with token value including Custom Field Token Values.CRM-3734
     $returnProperties = $mailing->getReturnProperties();
     $params = array('contact_id' => $session->get('userID'));
     $details = $mailing->getDetails($params, $returnProperties);
     $mime =& $mailing->compose(null, null, null, $session->get('userID'), $fromEmail, $fromEmail, true, $details[0][$session->get('userID')], $attachments);
     // there doesn't seem to be a way to get to Mail_Mime's text and HTML
     // parts, so we steal a peek at Mail_Mime's private properties, render
     // them and exit
     // note that preview does not display any attachments
     $mime->get();
     if ($type == 'html') {
         header('Content-Type: text/html; charset=utf-8');
         print $mime->_htmlbody;
     } else {
         header('Content-Type: text/plain; charset=utf-8');
         print $mime->_txtbody;
     }
     exit;
 }
예제 #12
0
 /**
  * Set variables up before form is built.
  *
  * @return void
  */
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $this->assign('context', $context);
     $values = array();
     $params['id'] = $this->_id;
     CRM_Grant_BAO_Grant::retrieve($params, $values);
     $grantType = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
     $grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
     $this->assign('grantType', $grantType[$values['grant_type_id']]);
     $this->assign('grantStatus', $grantStatus[$values['status_id']]);
     $grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
     foreach ($grantTokens as $token) {
         $this->assign($token, CRM_Utils_Array::value($token, $values));
     }
     if (isset($this->_id)) {
         $noteDAO = new CRM_Core_BAO_Note();
         $noteDAO->entity_table = 'civicrm_grant';
         $noteDAO->entity_id = $this->_id;
         if ($noteDAO->find(TRUE)) {
             $this->_noteId = $noteDAO->id;
         }
     }
     if (isset($this->_noteId)) {
         $this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note'));
     }
     // add Grant to Recent Items
     $url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
     $recentOther = array();
     if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::DELETE)) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=delete&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     }
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], NULL, $recentOther);
     $attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
     $this->assign('attachment', $attachment);
     $grantType = CRM_Core_DAO::getFieldValue("CRM_Grant_DAO_Grant", $this->_id, "grant_type_id");
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0, $grantType);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree, FALSE, NULL, NULL, NULL, $this->_id);
     $this->assign('id', $this->_id);
     $this->setPageTitle(ts('Grant'));
 }
예제 #13
0
파일: Send.php 프로젝트: kidaa30/yes
 /**
  * Class constructor.
  *
  * @param string $title
  * @param bool|int $action
  * @param bool $modal
  */
 public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE)
 {
     parent::__construct($title, $modal, NULL, FALSE, TRUE);
     $mailingID = CRM_Utils_Request::retrieve('mid', 'String', $this, FALSE, NULL);
     // also get the text and html file
     $txtFile = CRM_Utils_Request::retrieve('txtFile', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL);
     $config = CRM_Core_Config::singleton();
     if ($txtFile && file_exists($config->uploadDir . $txtFile)) {
         $this->set('textFilePath', $config->uploadDir . $txtFile);
     }
     $this->_stateMachine = new CRM_SMS_StateMachine_Send($this, $action, $mailingID);
     // create and instantiate the pages
     $this->addPages($this->_stateMachine, $action);
     // add all the actions
     $uploadNames = array_merge(array('textFile'), CRM_Core_BAO_File::uploadNames());
     $this->addActions(CRM_Core_Config::singleton()->uploadDir, $uploadNames);
 }
예제 #14
0
 /**
  * Create a new HRJobPension based on array-data
  *
  * @param array $params key-value pairs
  * @return CRM_HRJob_DAO_HRJobPension|NULL
  * 
  */
 public static function create($params)
 {
     $hook = empty($params['id']) ? 'create' : 'edit';
     $previousPensionRevisionId = null;
     if ($hook == 'create') {
         $previousRevisionResult = civicrm_api3('HRJobContractRevision', 'getcurrentrevision', array('sequential' => 1, 'jobcontract_id' => $params['jobcontract_id']));
         if (!empty($previousRevisionResult['values']['pension_revision_id'])) {
             $previousPensionRevisionId = $previousRevisionResult['values']['pension_revision_id'];
         }
     }
     $instance = parent::create($params);
     $revisionResult = civicrm_api3('HRJobContractRevision', 'get', array('sequential' => 1, 'id' => $instance->jobcontract_revision_id));
     $revision = CRM_Utils_Array::first($revisionResult['values']);
     if ($previousPensionRevisionId) {
         CRM_Core_BAO_File::copyEntityFile('civicrm_hrjobcontract_pension', $previousPensionRevisionId, 'civicrm_hrjobcontract_pension', $revision['pension_revision_id']);
     }
     return $instance;
 }
예제 #15
0
파일: Note.php 프로젝트: hguru/224Civi
 /**
  * View details of a note
  *
  * @return void
  * @access public
  */
 function view()
 {
     $note = new CRM_Core_DAO_Note();
     $note->id = $this->_id;
     if ($note->find(TRUE)) {
         $values = array();
         CRM_Core_DAO::storeValues($note, $values);
         $values['privacy'] = CRM_Core_OptionGroup::optionLabel('note_privacy', $values['privacy']);
         $this->assign('note', $values);
     }
     $comments = CRM_Core_BAO_Note::getNoteTree($values['id'], 1);
     if (!empty($comments)) {
         $this->assign('comments', $comments);
     }
     // add attachments part
     $currentAttachmentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_note', $this->_id);
     $this->assign('currentAttachmentInfo', $currentAttachmentInfo);
 }
예제 #16
0
파일: Search.php 프로젝트: hguru/224Civi
 /**
  * class constructor
  */
 function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE)
 {
     parent::__construct($title, $modal);
     $this->_stateMachine = new CRM_Event_StateMachine_Search($this, $action);
     // create and instantiate the pages
     $this->addPages($this->_stateMachine, $action);
     $session = CRM_Core_Session::singleton();
     $uploadNames = $session->get('uploadNames');
     if (!empty($uploadNames)) {
         $uploadNames = array_merge($uploadNames, CRM_Core_BAO_File::uploadNames());
     } else {
         $uploadNames = CRM_Core_BAO_File::uploadNames();
     }
     $config = CRM_Core_Config::singleton();
     $uploadDir = $config->uploadDir;
     // add all the actions
     $this->addActions($uploadDir, $uploadNames);
 }
예제 #17
0
 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $values = array();
     $params['id'] = $this->_id;
     require_once 'CRM/Grant/BAO/Grant.php';
     CRM_Grant_BAO_Grant::retrieve($params, $values);
     require_once 'CRM/Grant/PseudoConstant.php';
     $grantType = CRM_Grant_PseudoConstant::grantType();
     $grantStatus = CRM_Grant_PseudoConstant::grantStatus();
     $this->assign('grantType', $grantType[$values['grant_type_id']]);
     $this->assign('grantStatus', $grantStatus[$values['status_id']]);
     $grantTokens = array('amount_total', 'amount_requested', 'amount_granted', 'rationale', 'grant_report_received', 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date');
     foreach ($grantTokens as $token) {
         $this->assign($token, CRM_Utils_Array::value($token, $values));
     }
     if (isset($this->_id)) {
         require_once 'CRM/Core/BAO/Note.php';
         $noteDAO =& new CRM_Core_BAO_Note();
         $noteDAO->entity_table = 'civicrm_grant';
         $noteDAO->entity_id = $this->_id;
         if ($noteDAO->find(true)) {
             $this->_noteId = $noteDAO->id;
         }
     }
     if (isset($this->_noteId)) {
         $this->assign('note', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $this->_noteId, 'note'));
     }
     // add Grant to Recent Items
     require_once 'CRM/Utils/Recent.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     require_once 'CRM/Utils/Money.php';
     $url = CRM_Utils_System::url('civicrm/contact/view/grant', "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home");
     $title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')';
     CRM_Utils_Recent::add($title, $url, $values['id'], 'Grant', $values['contact_id'], null);
     require_once 'CRM/Core/BAO/File.php';
     $attachment = CRM_Core_BAO_File::attachmentInfo('civicrm_grant', $this->_id);
     $this->assign('attachment', $attachment);
     $groupTree =& CRM_Core_BAO_CustomGroup::getTree("Grant", $this, $this->_id, 0);
     CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree);
     $this->assign('id', $this->_id);
 }
예제 #18
0
파일: Search.php 프로젝트: ksecor/civicrm
 /**
  * class constructor
  */
 function __construct($title = null, $action = CRM_Core_Action::NONE, $modal = true)
 {
     require_once 'CRM/Event/StateMachine/Search.php';
     parent::__construct($title, $modal);
     $this->_stateMachine =& new CRM_Event_StateMachine_Search($this, $action);
     // create and instantiate the pages
     $this->addPages($this->_stateMachine, $action);
     require_once 'CRM/Core/BAO/File.php';
     $session =& CRM_Core_Session::singleton();
     $uploadNames = $session->get('uploadNames');
     if (!empty($uploadNames)) {
         $uploadNames = array_merge($uploadNames, CRM_Core_BAO_File::uploadNames());
     } else {
         $uploadNames = CRM_Core_BAO_File::uploadNames();
     }
     $config =& CRM_Core_Config::singleton();
     $uploadDir = $config->uploadDir;
     // add all the actions
     $this->addActions($uploadDir, $uploadNames);
 }
예제 #19
0
 /**
  * Class constructor.
  *
  * @param null $title
  * @param bool|int $action
  * @param bool $modal
  */
 public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE)
 {
     parent::__construct($title, $modal);
     $this->_stateMachine = new CRM_Tournament_Team_StateMachine($this, $action);
     // create and instantiate the pages
     $this->addPages($this->_stateMachine, $action);
     // hack for now, set Search to Basic mode
     //$this->_pages['Basic']->setAction(CRM_Core_Action::BASIC);
     // add all the actions
     $config = CRM_Core_Config::singleton();
     // to handle file type custom data
     $uploadDir = $config->uploadDir;
     $uploadNames = $this->get('uploadNames');
     if (!empty($uploadNames)) {
         $uploadNames = array_merge($uploadNames, CRM_Core_BAO_File::uploadNames());
     } else {
         $uploadNames = CRM_Core_BAO_File::uploadNames();
     }
     // add all the actions
     $this->addActions($uploadDir, $uploadNames);
 }
예제 #20
0
 /**  
  * Function to set variables up before form is built  
  *                                                            
  * @return void  
  * @access public  
  */
 public function preProcess()
 {
     //get the activity values
     $activityId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this);
     $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this);
     //check for required permissions, CRM-6264
     if ($activityId && !CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::VIEW)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     $session = CRM_Core_Session::singleton();
     if ($context != 'home') {
         $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity");
     } else {
         $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
     }
     $session->pushUserContext($url);
     $params = array('id' => $activityId);
     CRM_Activity_BAO_Activity::retrieve($params, $defaults);
     //set activity type name and description to template
     require_once 'CRM/Core/BAO/OptionValue.php';
     list($activityTypeName, $activityTypeDescription) = CRM_Core_BAO_OptionValue::getActivityTypeDetails($defaults['activity_type_id']);
     $this->assign('activityTypeName', $activityTypeName);
     $this->assign('activityTypeDescription', $activityTypeDescription);
     if (CRM_Utils_Array::value('mailingId', $defaults)) {
         $this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults);
         require_once 'CRM/Mailing/BAO/Mailing.php';
         $mailingReport =& CRM_Mailing_BAO_Mailing::report($this->_mailing_id, true);
         CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this);
         $this->assign('mailingReport', $mailingReport);
     }
     foreach ($defaults as $key => $value) {
         if (substr($key, -3) != '_id') {
             $values[$key] = $value;
         }
     }
     require_once 'CRM/Core/BAO/File.php';
     $values['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityId);
     $this->assign('values', $values);
 }
예제 #21
0
 /**
  * class constructor
  */
 function __construct($title = null, $action = CRM_Core_Action::NONE, $modal = true)
 {
     parent::__construct($title, $modal);
     require_once 'CRM/Group/StateMachine.php';
     $this->_stateMachine =& new CRM_Group_StateMachine($this, $action);
     // create and instantiate the pages
     $this->addPages($this->_stateMachine, $action);
     // hack for now, set Search to Basic mode
     $this->_pages['Basic']->setAction(CRM_Core_Action::BASIC);
     // add all the actions
     $config =& CRM_Core_Config::singleton();
     // to handle file type custom data
     $uploadDir = $config->uploadDir;
     require_once 'CRM/Core/BAO/File.php';
     $uploadNames = $this->get('uploadNames');
     if (!empty($uploadNames)) {
         $uploadNames = array_merge($uploadNames, CRM_Core_BAO_File::uploadNames());
     } else {
         $uploadNames = CRM_Core_BAO_File::uploadNames();
     }
     // add all the actions
     $this->addActions($uploadDir, $uploadNames);
 }
예제 #22
0
 /**
  * Run this page (figure out the action needed and perform it).
  *
  * @return void
  */
 public function run()
 {
     $session = CRM_Core_Session::singleton();
     $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'text');
     $type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'text');
     $options = array();
     $session->getVars($options, "CRM_Mailing_Controller_Send_{$qfKey}");
     //get the options if control come from search context, CRM-3711
     if (empty($options)) {
         $session->getVars($options, "CRM_Contact_Controller_Search_{$qfKey}");
     }
     // FIXME: the below and CRM_Mailing_Form_Test::testMail()
     // should be refactored
     $fromEmail = NULL;
     $mailing = new CRM_Mailing_BAO_Mailing();
     if (!empty($options)) {
         $mailing->id = $options['mailing_id'];
         $fromEmail = CRM_Utils_Array::value('from_email', $options);
     }
     $mailing->find(TRUE);
     CRM_Mailing_BAO_Mailing::tokenReplace($mailing);
     // get and format attachments
     $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id);
     //get details of contact with token value including Custom Field Token Values.CRM-3734
     $returnProperties = $mailing->getReturnProperties();
     $params = array('contact_id' => $session->get('userID'));
     $details = CRM_Utils_Token::getTokenDetails($params, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens(), get_class($this));
     $mime =& $mailing->compose(NULL, NULL, NULL, $session->get('userID'), $fromEmail, $fromEmail, TRUE, $details[0][$session->get('userID')], $attachments);
     if ($type == 'html') {
         CRM_Utils_System::setHttpHeader('Content-Type', 'text/html; charset=utf-8');
         print $mime->getHTMLBody();
     } else {
         CRM_Utils_System::setHttpHeader('Content-Type', 'text/plain; charset=utf-8');
         print $mime->getTXTBody();
     }
     CRM_Utils_System::civiExit();
 }
예제 #23
0
 /**
  * Set default values for the form.
  *
  * The default values are retrieved from the database.
  */
 public function setDefaultValues()
 {
     $defaults = $this->_values;
     if (empty($defaults['pdf_format_id'])) {
         $defaults['pdf_format_id'] = 'null';
     }
     if (empty($defaults['file_type'])) {
         $defaults['file_type'] = 0;
     }
     $this->_workflow_id = CRM_Utils_Array::value('workflow_id', $defaults);
     $this->assign('workflow_id', $this->_workflow_id);
     if ($this->_action & CRM_Core_Action::ADD) {
         $defaults['is_active'] = 1;
         //set the context for redirection after form submit or cancel
         $session = CRM_Core_Session::singleton();
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=user&reset=1'));
     }
     // FIXME: we need to fix the Cancel button here as we don’t know whether it’s a workflow template in buildQuickForm()
     if ($this->_action & CRM_Core_Action::UPDATE) {
         if ($this->_workflow_id) {
             $selectedChild = 'workflow';
         } else {
             $selectedChild = 'user';
         }
         $documentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_msg_template', $this->_id, TRUE);
         if (!empty($documentInfo)) {
             $defaults['file_type'] = 1;
             $this->_is_document = TRUE;
             $this->assign('attachment', $documentInfo);
         }
         $cancelURL = CRM_Utils_System::url('civicrm/admin/messageTemplates', "selectedChild={$selectedChild}&reset=1");
         $cancelURL = str_replace('&amp;', '&', $cancelURL);
         $this->addButtons(array(array('type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'), 'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"))));
     }
     return $defaults;
 }
예제 #24
0
파일: Send.php 프로젝트: ksecor/civicrm
 /**
  * class constructor
  */
 function __construct($title = null, $action = CRM_Core_Action::NONE, $modal = true)
 {
     require_once 'CRM/Mailing/StateMachine/Send.php';
     parent::__construct($title, $modal, null, false, true);
     $mailingID = CRM_Utils_Request::retrieve('mid', 'String', $this, false, null);
     // also get the text and html file
     $txtFile = CRM_Utils_Request::retrieve('txtFile', 'String', CRM_Core_DAO::$_nullObject, false, null);
     $htmlFile = CRM_Utils_Request::retrieve('htmlFile', 'String', CRM_Core_DAO::$_nullObject, false, null);
     $config =& CRM_Core_Config::singleton();
     if ($txtFile && file_exists($config->uploadDir . $txtFile)) {
         $this->set('textFilePath', $config->uploadDir . $txtFile);
     }
     if ($htmlFile && file_exists($config->uploadDir . $htmlFile)) {
         $this->set('htmlFilePath', $config->uploadDir . $htmlFile);
     }
     $this->_stateMachine =& new CRM_Mailing_StateMachine_Send($this, $action, $mailingID);
     // create and instantiate the pages
     $this->addPages($this->_stateMachine, $action);
     // add all the actions
     require_once 'CRM/Core/BAO/File.php';
     $uploadNames = array_merge(array('textFile', 'htmlFile'), CRM_Core_BAO_File::uploadNames());
     $config =& CRM_Core_Config::singleton();
     $this->addActions($config->uploadDir, $uploadNames);
 }
예제 #25
0
 /**
  * Process the view.
  *
  *
  * @return void
  */
 public function preProcess()
 {
     $contactID = CRM_Utils_Request::retrieve('cid', 'Integer', $this, TRUE);
     $activityID = CRM_Utils_Request::retrieve('aid', 'Integer', $this, TRUE);
     $revs = CRM_Utils_Request::retrieve('revs', 'Boolean', CRM_Core_DAO::$_nullObject);
     $caseID = CRM_Utils_Request::retrieve('caseID', 'Boolean', CRM_Core_DAO::$_nullObject);
     $activitySubject = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'subject');
     //check for required permissions, CRM-6264
     if ($activityID && !CRM_Activity_BAO_Activity::checkPermission($activityID, CRM_Core_Action::VIEW)) {
         CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
     }
     $this->assign('contactID', $contactID);
     $this->assign('caseID', $caseID);
     // CRM-9145
     $this->assign('activityID', $activityID);
     $xmlProcessor = new CRM_Case_XMLProcessor_Report();
     $report = $xmlProcessor->getActivityInfo($contactID, $activityID, TRUE);
     $attachmentUrl = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityID);
     if ($attachmentUrl) {
         $report['fields'][] = array('label' => 'Attachment(s)', 'value' => $attachmentUrl, 'type' => 'Link');
     }
     $tags = CRM_Core_BAO_EntityTag::getTag($activityID, 'civicrm_activity');
     if (!empty($tags)) {
         $allTag = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE));
         foreach ($tags as $tid) {
             $tags[$tid] = $allTag[$tid];
         }
         $report['fields'][] = array('label' => 'Tags', 'value' => implode('<br />', $tags), 'type' => 'String');
     }
     $this->assign('report', $report);
     $latestRevisionID = CRM_Activity_BAO_Activity::getLatestActivityId($activityID);
     $viewPriorActivities = array();
     $priorActivities = CRM_Activity_BAO_Activity::getPriorAcitivities($activityID);
     foreach ($priorActivities as $activityId => $activityValues) {
         if (CRM_Case_BAO_Case::checkPermission($activityId, 'view', NULL, $contactID)) {
             $viewPriorActivities[$activityId] = $activityValues;
         }
     }
     if ($revs) {
         CRM_Utils_System::setTitle(ts('Activity Revision History'));
         $this->assign('revs', $revs);
         $this->assign('result', $viewPriorActivities);
         $this->assign('subject', $activitySubject);
         $this->assign('latestRevisionID', $latestRevisionID);
     } else {
         if (count($viewPriorActivities) > 1) {
             $this->assign('activityID', $activityID);
         }
         if ($latestRevisionID != $activityID) {
             $this->assign('latestRevisionID', $latestRevisionID);
         }
     }
     $parentID = CRM_Activity_BAO_Activity::getParentActivity($activityID);
     if ($parentID) {
         $this->assign('parentID', $parentID);
     }
     //viewing activity should get diplayed in recent list.CRM-4670
     $activityTypeID = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'activity_type_id');
     $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
     $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
     $activityTargetContacts = CRM_Activity_BAO_ActivityContact::retrieveContactIdsByActivityId($activityID, $targetID);
     if (!empty($activityTargetContacts)) {
         $recentContactId = $activityTargetContacts[0];
     } else {
         $recentContactId = $contactID;
     }
     if (!isset($caseID)) {
         $caseID = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseActivity', $activityID, 'case_id', 'activity_id');
     }
     $url = CRM_Utils_System::url('civicrm/case/activity/view', "reset=1&aid={$activityID}&cid={$recentContactId}&caseID={$caseID}&context=home");
     $recentContactDisplay = CRM_Contact_BAO_Contact::displayName($recentContactId);
     // add the recently created Activity
     $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE);
     $title = "";
     if (isset($activitySubject)) {
         $title = $activitySubject . ' - ';
     }
     $title = $title . $recentContactDisplay . ' (' . $activityTypes[$activityTypeID] . ')';
     $recentOther = array();
     if (CRM_Case_BAO_Case::checkPermission($activityID, 'edit')) {
         $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/case/activity', "reset=1&action=update&id={$activityID}&cid={$recentContactId}&caseid={$caseID}&context=home");
     }
     if (CRM_Case_BAO_Case::checkPermission($activityID, 'delete')) {
         $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/case/activity', "reset=1&action=delete&id={$activityID}&cid={$recentContactId}&caseid={$caseID}&context=home");
     }
     CRM_Utils_Recent::add($title, $url, $activityID, 'Activity', $recentContactId, $recentContactDisplay, $recentOther);
 }
function _civicrm_api3_pcpteams_getMoreInfo(&$params)
{
    foreach ($params as $pcpId => $pcpValues) {
        $entityFile = CRM_Core_BAO_File::getEntityFile('civicrm_pcp', $pcpId);
        $imageUrl = "";
        $fileId = NULL;
        if ($entityFile) {
            $fileInfo = reset($entityFile);
            $fileId = $fileInfo['fileID'];
            $imageUrl = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileId}&eid={$pcpId}");
        }
        $pcpBlockId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'pcp_block_id', 'id');
        if ($pcpBlockId) {
            $contributionPageId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCPBlock', $pcpBlockId, 'target_entity_id', 'id');
        }
        $donateUrl = CRM_Utils_System::url('civicrm/contribute/transact', 'id=' . $contributionPageId . '&pcpId=' . $pcpId . '&reset=1');
        $aContactTypes = CRM_Contact_BAO_Contact::getContactTypes($pcpValues['contact_id']);
        $isTeamPcp = in_array('Team', $aContactTypes) ? TRUE : FALSE;
        $params[$pcpId]['page_title'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $pcpValues['page_id'], 'title');
        $params[$pcpId]['amount_raised'] = civicrm_api3_pcpteams_getAmountRaised(array('pcp_id' => $pcpId, 'version' => 3));
        $params[$pcpId]['image_url'] = $imageUrl ? $imageUrl : CRM_Pcpteams_Constant::C_DEFAULT_PROFILE_PIC;
        $params[$pcpId]['image_id'] = $fileId;
        $params[$pcpId]['donate_url'] = $donateUrl;
        $params[$pcpId]['is_teampage'] = $isTeamPcp;
        //calculate percentage
        $percentage = 0;
        if (isset($pcpValues['goal_amount']) && number_format($pcpValues['goal_amount']) != '0') {
            $percentage = number_format($params[$pcpId]['amount_raised'] / $params[$pcpId]['goal_amount'] * 100);
        }
        if (isset($pcpValues['currency'])) {
            $params[$pcpId]['currency_symbol'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_Currency', $pcpValues['currency'], 'symbol', 'name');
        }
        $params[$pcpId]['percentage'] = $percentage;
        // check the user has pending request
        $pendingDetails = civicrm_api3_pcpteams_getMyPendingTeam(array('contact_id' => $pcpValues['contact_id']));
        $params[$pcpId]['pending_team_pcp_id'] = isset($pendingDetails['values'][0]) ? $pendingDetails['values'][0]['teamPcpId'] : NULL;
        $params[$pcpId]['pending_team_relationship_id'] = isset($pendingDetails['values'][0]) ? $pendingDetails['values'][0]['relationship_id'] : NULL;
    }
}
예제 #27
0
 /**
  * Send activity as attachment.
  *
  * @param object $activity
  * @param array $mailToContacts
  * @param array $params
  *
  * @return bool
  */
 public static function sendToAssignee($activity, $mailToContacts, $params = array())
 {
     if (!CRM_Utils_Array::crmIsEmptyArray($mailToContacts)) {
         $clientID = CRM_Utils_Array::value('client_id', $params);
         $caseID = CRM_Utils_Array::value('case_id', $params);
         $ics = new CRM_Activity_BAO_ICalendar($activity);
         $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id);
         $ics->addAttachment($attachments, $mailToContacts);
         $result = CRM_Case_BAO_Case::sendActivityCopy($clientID, $activity->id, $mailToContacts, $attachments, $caseID);
         $ics->cleanup();
         return $result;
     }
     return FALSE;
 }
예제 #28
0
파일: File.php 프로젝트: hguru/224Civi
 /**
  * function to delete a file attachment from an entity table / entity ID
  *
  * @static
  * @access public
  */
 static function deleteAttachment()
 {
     $params = array();
     $params['entityTable'] = CRM_Utils_Request::retrieve('entityTable', 'String', CRM_Core_DAO::$_nullObject, TRUE);
     $params['entityID'] = CRM_Utils_Request::retrieve('entityID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
     $params['fileID'] = CRM_Utils_Request::retrieve('fileID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE);
     $signature = CRM_Utils_Request::retrieve('_sgn', 'String', CRM_Core_DAO::$_nullObject, TRUE);
     $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), self::$_signableFields);
     if (!$signer->validate($signature, $params)) {
         CRM_Core_Error::fatal('Request signature is invalid');
     }
     CRM_Core_BAO_File::deleteEntityFile($params['entityTable'], $params['entityID'], NULL, $params['fileID']);
 }
예제 #29
0
 /**
  * Process the form submission.
  *
  *
  * @param array $params
  * @return array|null
  */
 public function postProcess($params = NULL)
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         $deleteParams = array('id' => $this->_activityId);
         $moveToTrash = CRM_Case_BAO_Case::isCaseActivity($this->_activityId);
         CRM_Activity_BAO_Activity::deleteActivity($deleteParams, $moveToTrash);
         // delete tags for the entity
         $tagParams = array('entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId);
         CRM_Core_BAO_EntityTag::del($tagParams);
         CRM_Core_Session::setStatus(ts("Selected Activity has been deleted successfully."), ts('Record Deleted'), 'success');
         return NULL;
     }
     // store the submitted values in an array
     if (!$params) {
         $params = $this->controller->exportValues($this->_name);
     }
     // Set activity type id.
     if (empty($params['activity_type_id'])) {
         $params['activity_type_id'] = $this->_activityTypeId;
     }
     if (!empty($params['hidden_custom']) && !isset($params['custom'])) {
         $customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
         $customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
         $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_activityId, 'Activity');
     }
     // store the date with proper format
     $params['activity_date_time'] = CRM_Utils_Date::processDate($params['activity_date_time'], $params['activity_date_time_time']);
     // format params as arrays
     foreach (array('target', 'assignee', 'followup_assignee') as $name) {
         if (!empty($params["{$name}_contact_id"])) {
             $params["{$name}_contact_id"] = explode(',', $params["{$name}_contact_id"]);
         } else {
             $params["{$name}_contact_id"] = array();
         }
     }
     // get ids for associated contacts
     if (!$params['source_contact_id']) {
         $params['source_contact_id'] = $this->_currentUserId;
     }
     if (isset($this->_activityId)) {
         $params['id'] = $this->_activityId;
     }
     // add attachments as needed
     CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_activity', $this->_activityId);
     $activity = array();
     if (!empty($params['is_multi_activity']) && !CRM_Utils_Array::crmIsEmptyArray($params['target_contact_id'])) {
         $targetContacts = $params['target_contact_id'];
         foreach ($targetContacts as $targetContactId) {
             $params['target_contact_id'] = array($targetContactId);
             // save activity
             $activity[] = $this->processActivity($params);
         }
     } else {
         // save activity
         $activity = $this->processActivity($params);
     }
     $activityIds = empty($this->_activityIds) ? array($this->_activityId) : $this->_activityIds;
     foreach ($activityIds as $activityId) {
         // set params for repeat configuration in create mode
         $params['entity_id'] = $activityId;
         $params['entity_table'] = 'civicrm_activity';
         if (!empty($params['entity_id']) && !empty($params['entity_table'])) {
             $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($params['entity_id'], $params['entity_table']);
             if ($checkParentExistsForThisId) {
                 $params['parent_entity_id'] = $checkParentExistsForThisId;
                 $scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($checkParentExistsForThisId, $params['entity_table']);
             } else {
                 $params['parent_entity_id'] = $params['entity_id'];
                 $scheduleReminderDetails = CRM_Core_BAO_RecurringEntity::getReminderDetailsByEntityId($params['entity_id'], $params['entity_table']);
             }
             if (property_exists($scheduleReminderDetails, 'id')) {
                 $params['schedule_reminder_id'] = $scheduleReminderDetails->id;
             }
         }
         $params['dateColumns'] = array('activity_date_time');
         // Set default repetition start if it was not provided.
         if (empty($params['repetition_start_date'])) {
             $params['repetition_start_date'] = $params['activity_date_time'];
         }
         // unset activity id
         unset($params['id']);
         $linkedEntities = array(array('table' => 'civicrm_activity_contact', 'findCriteria' => array('activity_id' => $activityId), 'linkedColumns' => array('activity_id'), 'isRecurringEntityRecord' => FALSE));
         CRM_Core_Form_RecurringEntity::postProcess($params, 'civicrm_activity', $linkedEntities);
     }
     return array('activity' => $activity);
 }
예제 #30
0
 public function addUploadAction($uploadDir, $uploadNames)
 {
     if (empty($uploadDir)) {
         $config = CRM_Core_Config::singleton();
         $uploadDir = $config->uploadDir;
     }
     if (empty($uploadNames)) {
         $uploadNames = $this->get('uploadNames');
         if (!empty($uploadNames)) {
             $uploadNames = array_merge($uploadNames, CRM_Core_BAO_File::uploadNames());
         } else {
             $uploadNames = CRM_Core_BAO_File::uploadNames();
         }
     }
     $action = new CRM_Core_QuickForm_Action_Upload($this->_stateMachine, $uploadDir, $uploadNames);
     $this->addAction('upload', $action);
 }