Exemplo n.º 1
0
 public function _on_updated()
 {
     if ($this->_register_prober) {
         $args = array('person' => $this->guid);
         midcom_services_at_interface::register(time() + 60, 'org.openpsa.contacts', 'check_url', $args);
     }
 }
Exemplo n.º 2
0
 /**
  * Function to disable account for time period given in config
  *
  * @return boolean - indicates success
  */
 public function disable_account()
 {
     $this->_account = midcom_core_account::get($this->_person);
     $timeframe_minutes = $this->_config->get('password_block_timeframe_min');
     if ($timeframe_minutes == 0) {
         return false;
     }
     $release_time = time() + $timeframe_minutes * 60;
     $args = array('guid' => $this->_person->guid, 'parameter_name' => 'org_openpsa_user_blocked_account', 'password' => 'account_password');
     $qb = midcom_services_at_entry_dba::new_query_builder();
     $qb->add_constraint('argumentsstore', '=', serialize($args));
     $qb->add_constraint('status', '=', midcom_services_at_entry_dba::SCHEDULED);
     $results = $qb->execute();
     if (sizeof($results) > 0) {
         //the account is already blocked, so we just extend the block's duration
         $entry = $results[0];
         $entry->start = $release_time;
         return $entry->update();
     }
     if (!midcom_services_at_interface::register($release_time, 'org.openpsa.user', 'reopen_account', $args)) {
         throw new midcom_error("Failed to register interface for re_open the user account, last Midgard error was: " . midcom_connection::get_error_string());
     }
     $this->_person->set_parameter("org_openpsa_user_blocked_account", "account_password", $this->_account->get_password());
     $this->_account->set_password('', false);
     return $this->_account->save();
 }
Exemplo n.º 3
0
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_send($handler_id, array &$data)
 {
     $composed = $this->_prepare_send($data);
     // TODO: Figure out the correct use of style elements, this is how it was but it's not exactly optimal...
     switch ($handler_id) {
         case 'test_send_message':
             // on-line sned
             $data['message_obj']->send_output = true;
             $data['message_obj']->send($composed, $data['compose_from'], $data['compose_subject'], $data['message_array']);
             break;
         default:
             // Schedule background send
             debug_add('Registering background send job to start on: ' . date('Y-m-d H:i:s', $data['send_start']));
             $at_handler_arguments = array('batch' => 1, 'url_base' => $data['batch_url_base_full']);
             debug_add("---SHOW SEND---" . $data['batch_url_base_full'], MIDCOM_LOG_ERROR);
             $bool = midcom_services_at_interface::register($data['send_start'], 'org.openpsa.directmarketing', 'background_send_message', $at_handler_arguments);
             debug_add("--- RESULT register:" . $bool, MIDCOM_LOG_ERROR);
             midcom_show_style('send-start');
             break;
     }
 }
Exemplo n.º 4
0
 /**
  * Schedules a background memberships update for a smart campaign
  */
 function schedule_update_smart_campaign_members($time = false)
 {
     if (!$time) {
         $time = time();
     }
     if (!$this->id) {
         debug_add('This campaign has no id (maybe not created yet?), aborting', MIDCOM_LOG_ERROR);
         return false;
     }
     if ($this->orgOpenpsaObtype != self::TYPE_SMART) {
         debug_add("This (id #{$this->id}) is not a smart campaign, aborting", MIDCOM_LOG_ERROR);
         return false;
     }
     midcom::get('auth')->request_sudo('org.openpsa.directmarketing');
     $stat = midcom_services_at_interface::register($time, 'org.openpsa.directmarketing', 'background_update_campaign_members', array('campaign_guid' => $this->guid));
     if (!$stat) {
         debug_add('Failed to register an AT job for members update, errstr: ' . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
         midcom::get('auth')->drop_sudo();
         return false;
     }
     $this->parameter('org.openpsa.directmarketing_smart_campaign', 'members_update_scheduled', $time);
     midcom::get('auth')->drop_sudo();
     return true;
 }
Exemplo n.º 5
0
 /**
  * Sends $content to all members of the campaign
  */
 function send_bg($url_base, $batch, &$content, &$from, &$subject, &$data_array)
 {
     midcom::get()->disable_limits();
     //For first batch (they start from 1 instead of 0) make sure we have smart campaign members up to date
     if ($batch == 1 && !$this->test_mode) {
         $this->_check_campaign_up_to_date();
     }
     // Register sendStarted if not already set (and we're not in test mode)
     if (!$this->test_mode) {
         if (!$this->sendStarted) {
             $this->sendStarted = time();
             $this->update();
         }
     }
     switch ($this->orgOpenpsaObtype) {
         case self::EMAIL_TEXT:
         case self::EMAIL_HTML:
             list($status, $reg_next) = $this->send_email_bg($batch, $subject, $content, $from, $data_array);
             break;
         case self::SMS:
             list($status, $reg_next) = $this->send_sms_bg($batch, $content, $from, $data_array);
             break;
         case self::MMS:
             list($status, $reg_next) = $this->send_mms_bg($batch, $content, $from, $data_array);
             break;
         case self::CALL:
             //This quite naturally cannot be handled via web
         //This quite naturally cannot be handled via web
         case self::SNAILMAIL:
             //While this can in theory be automated we don't do it yet
         //While this can in theory be automated we don't do it yet
         case self::FAX:
             //See above
         //See above
         default:
             return false;
     }
     debug_add("status: {$status}, reg_next: {$reg_next}");
     if ($reg_next) {
         //register next batch
         $args = array('batch' => $batch + 1, 'url_base' => $url_base);
         debug_add("Registering batch #{$args['batch']} for {$args['url_base']}");
         midcom::get('auth')->request_sudo('org.openpsa.directmarketing');
         $atstat = midcom_services_at_interface::register(time() + 60, 'org.openpsa.directmarketing', 'background_send_message', $args);
         midcom::get('auth')->drop_sudo();
         if (!$atstat) {
             debug_add("FAILED to register batch #{$args['batch']} for {$args['url_base']}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
             return false;
         }
     } else {
         // Last batch done, register sendCompleted if we're not in test mode
         if (!$this->test_mode) {
             $this->sendCompleted = time();
             $this->update();
         }
     }
     return $status;
 }