Esempio n. 1
0
 public function testHookCron()
 {
     $hook = $this->getMock('stdClass', array('civicrm_cron'));
     $hook->expects($this->once())->method('civicrm_cron')->with($this->isInstanceOf('CRM_Core_JobManager'));
     CRM_Utils_Hook::singleton()->setMock($hook);
     $jobManager = new CRM_Core_JobManager();
     $jobManager->execute(FALSE);
 }
Esempio n. 2
0
/**
 * Dumb wrapper to execute scheduled jobs. Always creates success - errors
 * and results are handled in the job log.
 *
 * @param  array   	  $params (reference ) input parameters
 *
 * @return array API Result Array
 *
 * @static void
 * @access public
 *
 */
function civicrm_api3_job_execute($params)
{
    require_once 'CRM/Core/JobManager.php';
    $facility = new CRM_Core_JobManager();
    $facility->execute(CRM_Utils_Array::value('auth', $params, TRUE));
    // always creates success - results are handled elsewhere
    return civicrm_api3_create_success();
}
 public function callApi()
 {
     require_once 'api/api.php';
     //  CRM-9822 -'execute' action always goes thru Job api and always writes to log
     if ($this->_action != 'execute' && $this->_joblog) {
         require_once 'CRM/Core/JobManager.php';
         $facility = new CRM_Core_JobManager();
         $facility->setSingleRunParams($this->_entity, $this->_action, $this->_params, 'From Cli.php');
         $facility->executeJobByAction($this->_entity, $this->_action);
     } else {
         // CRM-9822 cli.php calls don't require site-key, so bypass site-key authentication
         $this->_params['auth'] = FALSE;
         $result = civicrm_api($this->_entity, $this->_action, $this->_params);
     }
     if ($result['is_error'] != 0) {
         $this->_log($result['error_message']);
         return FALSE;
     } elseif ($this->_output) {
         print_r($result['values']);
     }
     return TRUE;
 }
Esempio n. 4
0
 /**
  */
 public static function executeScheduledJobs()
 {
     $facility = new CRM_Core_JobManager();
     $facility->execute(FALSE);
     $redirectUrl = self::url('civicrm/admin/job', 'reset=1');
     CRM_Core_Session::setStatus(ts('Scheduled jobs have been executed according to individual timing settings. Please check log for messages.'), ts('Complete'), 'success');
     CRM_Utils_System::redirect($redirectUrl);
 }
Esempio n. 5
0
File: Job.php Progetto: kidaa30/yes
 /**
  * Browse all jobs.
  *
  * @param null $action
  *
  * @return void
  */
 public function browse($action = NULL)
 {
     // using Export action for Execute. Doh.
     if ($this->_action & CRM_Core_Action::EXPORT) {
         $jm = new CRM_Core_JobManager();
         $jm->executeJobById($this->_id);
         CRM_Core_Session::setStatus(ts('Selected Scheduled Job has been executed. See the log for details.'), ts("Executed"), "success");
     }
     $sj = new CRM_Core_JobManager();
     $rows = $temp = array();
     foreach ($sj->jobs as $job) {
         $action = array_sum(array_keys($this->links()));
         // update enable/disable links.
         // CRM-9868- remove enable action for jobs that should never be run automatically via execute action or runjobs url
         if ($job->api_action == 'process_membership_reminder_date' || $job->api_action == 'update_greeting') {
             $action -= CRM_Core_Action::ENABLE;
             $action -= CRM_Core_Action::DISABLE;
         } elseif ($job->is_active) {
             $action -= CRM_Core_Action::ENABLE;
         } else {
             $action -= CRM_Core_Action::DISABLE;
         }
         $job->action = CRM_Core_Action::formLink(self::links(), $action, array('id' => $job->id), ts('more'), FALSE, 'job.manage.action', 'Job', $job->id);
         $rows[] = get_object_vars($job);
     }
     $this->assign('rows', $rows);
 }
Esempio n. 6
0
| See the GNU Affero General Public License for more details.        |
|                                                                    |
| You should have received a copy of the GNU Affero General Public   |
| License and the CiviCRM Licensing Exception along                  |
| with this program; if not, contact CiviCRM LLC                     |
| at info[AT]civicrm[DOT]org. If you have questions about the        |
| GNU Affero General Public License or the licensing of CiviCRM,     |
| see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+--------------------------------------------------------------------+
*/
require_once '../civicrm.config.php';
require_once 'CRM/Core/Config.php';
require_once 'CRM/Utils/Request.php';
$config = CRM_Core_Config::singleton();
CRM_Utils_System::authenticateScript(TRUE);
$job = CRM_Utils_Request::retrieve('job', 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
require_once 'CRM/Core/JobManager.php';
$facility = new CRM_Core_JobManager();
if ($job === NULL) {
    $facility->execute();
} else {
    $ignored = array("name", "pass", "key", "job");
    $params = array();
    foreach ($_REQUEST as $name => $value) {
        if (!in_array($name, $ignored)) {
            $params[$name] = CRM_Utils_Request::retrieve($name, 'String', CRM_Core_DAO::$_nullArray, FALSE, NULL, 'REQUEST');
        }
    }
    $facility->setSingleRunParams('job', $job, $params, 'From cron.php');
    $facility->executeJobByAction('job', $job);
}
Esempio n. 7
0
/**
 * Dumb wrapper to execute scheduled jobs.
 *
 * Always creates success - errors and results are handled in the job log.
 *
 * @param array $params
 *   input parameters (unused).
 *
 * @return array
 *   API Result Array
 */
function civicrm_api3_job_execute($params)
{
    $facility = new CRM_Core_JobManager();
    $facility->execute(FALSE);
    // Always creates success - results are handled elsewhere.
    return civicrm_api3_create_success(1, $params, 'Job');
}
Esempio n. 8
0
 /**
  * Implementation of command 'process-mail-queue'
  */
 private function processMailQueue()
 {
     civicrm_initialize();
     if (substr(CRM_Utils_System::version(), 0, 3) >= '4.3') {
         $job = new CRM_Core_JobManager();
         $job->executeJobByAction('job', 'process_mailing');
         WP_CLI::success("Executed 'process_mailing' job.");
     } else {
         $result = civicrm_api('Mailing', 'Process', array('version' => 3));
         if ($result['is_error']) {
             WP_CLI::error($result['error_message']);
         }
     }
 }