public function run()
 {
     global $ilSetting, $ilDB;
     $status = ilCronJobResult::STATUS_NO_ACTION;
     $days_before = $ilSetting->get('ch_reminder_days');
     $now = new ilDateTime(time(), IL_CAL_UNIX);
     $limit = clone $now;
     $limit->increment(IL_CAL_DAY, $days_before);
     $counter = 0;
     $query = 'SELECT * FROM booking_user ' . 'JOIN cal_entries ON entry_id = cal_id ' . 'WHERE notification_sent = ' . $ilDB->quote(0, 'integer') . ' ' . 'AND starta > ' . $ilDB->quote($now->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp') . ' ' . 'AND starta <= ' . $ilDB->quote($limit->get(IL_CAL_DATETIME, '', ilTimeZone::UTC), 'timestamp');
     $res = $ilDB->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         include_once 'Services/Calendar/classes/class.ilCalendarMailNotification.php';
         $mail = new ilCalendarMailNotification();
         $mail->setAppointmentId($row->entry_id);
         $mail->setRecipients(array($row->user_id));
         $mail->setType(ilCalendarMailNotification::TYPE_BOOKING_REMINDER);
         $mail->send();
         // update notification
         $query = 'UPDATE booking_user ' . 'SET notification_sent = ' . $ilDB->quote(1, 'integer') . ' ' . 'WHERE user_id = ' . $ilDB->quote($row->user_id, 'integer') . ' ' . 'AND entry_id = ' . $ilDB->quote($row->entry_id, 'integer');
         $ilDB->manipulate($query);
         $counter++;
     }
     if ($counter) {
         $status = ilCronJobResult::STATUS_OK;
     }
     $result = new ilCronJobResult();
     $result->setStatus($status);
     return $result;
 }
 public function run()
 {
     require_once 'Services/Mail/classes/class.ilMailSummaryNotification.php';
     $msn = new ilMailSummaryNotification();
     $msn->send();
     $result = new ilCronJobResult();
     $result->setStatus(ilCronJobResult::STATUS_OK);
     return $result;
 }
 public function run()
 {
     require_once 'Services/Payment/classes/class.ilPaymentNotification.php';
     $msn = new ilPaymentNotification();
     $msn->send();
     include_once './Services/Payment/classes/class.ilUserDefinedInvoiceNumber.php';
     if (ilUserDefinedInvoiceNumber::_isUDInvoiceNumberActive()) {
         $msn = new ilUserDefinedInvoiceNumber();
         $msn->cronCheck();
     }
     $result = new ilCronJobResult();
     $result->setStatus(ilCronJobResult::STATUS_OK);
     return $result;
 }
 public function run()
 {
     require_once './Services/WebDAV/classes/class.ilDiskQuotaChecker.php';
     if (ilDiskQuotaActivationChecker::_isActive()) {
         ilDiskQuotaChecker::_updateDiskUsageReport();
         if (ilDiskQuotaActivationChecker::_isReminderMailActive()) {
             ilDiskQuotaChecker::_sendReminderMails();
         }
         if (ilDiskQuotaActivationChecker::_isSummaryMailActive()) {
             ilDiskQuotaChecker::_sendSummaryMails();
         }
     }
     $result = new ilCronJobResult();
     $result->setStatus(ilCronJobResult::STATUS_OK);
     return $result;
 }
 public function run()
 {
     // all date related operations are based on this timestamp
     // should be midnight of yesterday (see gatherUserData()) to always have full day
     $this->date = strtotime("yesterday");
     $status = ilCronJobResult::STATUS_NO_ACTION;
     $message = array();
     $count = 0;
     $count += $this->gatherCourseLPData();
     $count += $this->gatherTypesData();
     $count += $this->gatherUserData();
     if ($count) {
         $status = ilCronJobResult::STATUS_OK;
     }
     $result = new ilCronJobResult();
     $result->setStatus($status);
     return $result;
 }
 public function run()
 {
     $status = ilCronJobResult::STATUS_NO_ACTION;
     $message = array();
     $count = 0;
     include_once "Modules/Exercise/classes/class.ilExAssignment.php";
     foreach (ilExAssignment::getPendingFeedbackNotifications() as $ass_id) {
         if (ilExAssignment::sendFeedbackNotifications($ass_id)) {
             $count++;
         }
     }
     if ($count) {
         $status = ilCronJobResult::STATUS_OK;
     }
     $result = new ilCronJobResult();
     $result->setStatus($status);
     return $result;
 }
 public function run()
 {
     global $ilLog, $ilDB;
     $status = ilCronJobResult::STATUS_NO_ACTION;
     include_once './Services/LinkChecker/classes/class.ilLinkChecker.php';
     $link_checker =& new ilLinkChecker($ilDB);
     $link_checker->setMailStatus(true);
     $link_checker->checkLinks();
     $counter = 0;
     foreach ($link_checker->getLogMessages() as $message) {
         $ilLog->write($message);
         $counter++;
     }
     if ($counter) {
         $status = ilCronJobResult::STATUS_OK;
     }
     $result = new ilCronJobResult();
     $result->setStatus($status);
     return $result;
 }
 public function run()
 {
     global $ilDB, $ilLog, $lng;
     $status = ilCronJobResult::STATUS_NO_ACTION;
     $now = time();
     $two_weeks_in_seconds = $now + 60 * 60 * 24 * 14;
     // #14630
     // all users who are currently active and expire in the next 2 weeks
     $query = "SELECT * FROM usr_data,usr_pref " . "WHERE time_limit_message = '0' " . "AND time_limit_unlimited = '0' " . "AND time_limit_from < " . $ilDB->quote($now, "integer") . " " . "AND time_limit_until > " . $ilDB->quote($now, "integer") . " " . "AND time_limit_until < " . $ilDB->quote($two_weeks_in_seconds, "integer") . " " . "AND usr_data.usr_id = usr_pref.usr_id " . "AND keyword = " . $ilDB->quote("language", "text");
     $res = $ilDB->query($query);
     while ($row = $ilDB->fetchObject($res)) {
         include_once 'Services/Mail/classes/class.ilMimeMail.php';
         $data['expires'] = $row->time_limit_until;
         $data['email'] = $row->email;
         $data['login'] = $row->login;
         $data['usr_id'] = $row->usr_id;
         $data['language'] = $row->value;
         $data['owner'] = $row->time_limit_owner;
         // Send mail
         $mail =& new ilMimeMail();
         $mail->From('noreply');
         $mail->To($data['email']);
         $mail->Subject($this->txt($data['language'], 'account_expires_subject'), true);
         $mail->Body($this->txt($data['language'], 'account_expires_body') . " " . strftime('%Y-%m-%d %R', $data['expires']));
         $mail->send();
         // set status 'mail sent'
         $query = "UPDATE usr_data SET time_limit_message = '1' WHERE usr_id = '" . $data['usr_id'] . "'";
         $ilDB->query($query);
         // Send log message
         $ilLog->write('Cron: (checkUserAccounts()) sent message to ' . $data['login'] . '.');
         $this->counter++;
     }
     $this->checkNotConfirmedUserAccounts();
     if ($this->counter) {
         $status = ilCronJobResult::STATUS_OK;
     }
     $result = new ilCronJobResult();
     $result->setStatus($status);
     return $result;
 }
    public function run()
    {
        global $ilDB;
        if ($ilDB->getDBType() == 'oracle') {
            $res1 = $ilDB->queryF('
				SELECT addressbook.addr_id, 
					   usr_data.firstname,
					   usr_data.lastname, 
					   (CASE WHEN epref.value = %s THEN usr_data.email ELSE addressbook.email END) email
				FROM addressbook
				INNER JOIN usr_data ON usr_data.login = addressbook.login
				INNER JOIN usr_pref ppref ON ppref.usr_id = usr_data.usr_id AND ppref.keyword = %s AND ppref.value != %s
				LEFT JOIN usr_pref epref ON epref.usr_id = usr_data.usr_id AND epref.keyword = %s
				WHERE addressbook.auto_update = %s', array('text', 'text', 'text', 'text', 'integer'), array('y', 'public_profile', 'n', 'public_email', 1));
            $stmt = $ilDB->prepare('
				UPDATE addressbook 
				SET firstname = ?,
					lastname = ?,
					email = ?
				WHERE addr_id = ?', array('text', 'text', 'text', 'integer'));
            while ($row = $ilDB->fetchAssoc($res1)) {
                $ilDB->execute($stmt, array($row['firstname'], $row['lastname'], $row['email'], $row['addr_id']));
            }
        } else {
            $ilDB->queryF('
				UPDATE addressbook
				INNER JOIN usr_data ON usr_data.login = addressbook.login
				INNER JOIN usr_pref ppref ON ppref.usr_id = usr_data.usr_id AND ppref.keyword = %s AND ppref.value != %s
				LEFT JOIN usr_pref epref ON epref.usr_id = usr_data.usr_id AND epref.keyword = %s
				SET
				addressbook.firstname = usr_data.firstname,
				addressbook.lastname = usr_data.lastname,
				addressbook.email =  (CASE WHEN epref.value = %s THEN usr_data.email ELSE addressbook.email  END)
				WHERE addressbook.auto_update = %s', array('text', 'text', 'text', 'text', 'integer'), array('public_profile', 'n', 'public_email', 'y', 1));
        }
        $result = new ilCronJobResult();
        $result->setStatus(ilCronJobResult::STATUS_OK);
        return $result;
    }
 public function run()
 {
     global $tree;
     include_once "Modules/Survey/classes/class.ilObjSurvey.php";
     $status = ilCronJobResult::STATUS_NO_ACTION;
     $message = array();
     $root = $tree->getNodeData(ROOT_FOLDER_ID);
     foreach ($tree->getSubTree($root, false, "svy") as $svy_ref_id) {
         $svy = new ilObjSurvey($svy_ref_id);
         if ($svy->checkReminder()) {
             $message[] = $svy_ref_id;
             $status = ilCronJobResult::STATUS_OK;
         }
     }
     $result = new ilCronJobResult();
     $result->setStatus($status);
     if (sizeof($message)) {
         $result->setMessage("Ref-Ids: " . implode(", ", $message));
         $result->setCode("#" . sizeof($message));
     }
     return $result;
 }
 public function run()
 {
     global $ilLog, $ilUser, $ilDB;
     $status = ilCronJobResult::STATUS_NO_ACTION;
     include_once './Services/LinkChecker/classes/class.ilLinkChecker.php';
     $counter = 0;
     foreach (ilUtil::_getObjectsByOperations('webr', 'write', $ilUser->getId(), -1) as $node) {
         if (!is_object($tmp_webr = ilObjectFactory::getInstanceByRefId($node, false))) {
             continue;
         }
         $tmp_webr->initLinkResourceItemsObject();
         // Set all link to valid. After check invalid links will be set to invalid
         $link_checker =& new ilLinkChecker($ilDB);
         $link_checker->setMailStatus(true);
         $link_checker->setCheckPeriod($this->__getCheckPeriod());
         $link_checker->setObjId($tmp_webr->getId());
         $tmp_webr->items_obj->updateValidByCheck($this->__getCheckPeriod());
         foreach ($link_checker->checkWebResourceLinks() as $invalid) {
             $tmp_webr->items_obj->readItem($invalid['page_id']);
             $tmp_webr->items_obj->setActiveStatus(false);
             $tmp_webr->items_obj->setValidStatus(false);
             $tmp_webr->items_obj->setDisableCheckStatus(true);
             $tmp_webr->items_obj->setLastCheckDate(time());
             $tmp_webr->items_obj->update(false);
         }
         $tmp_webr->items_obj->updateLastCheck($this->__getCheckPeriod());
         foreach ($link_checker->getLogMessages() as $message) {
             $ilLog->write($message);
             $counter++;
         }
     }
     if ($counter) {
         $status = ilCronJobResult::STATUS_OK;
     }
     $result = new ilCronJobResult();
     $result->setStatus($status);
     return $result;
 }
 public function run()
 {
     global $ilSetting;
     $status = ilCronJobResult::STATUS_NO_ACTION;
     $error_message = null;
     try {
         include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
         ilRpcClientFactory::factory('RPCIndexHandler')->index(CLIENT_ID . '_' . $ilSetting->get('inst_id', 0), true);
     } catch (XML_RPC2_FaultException $e) {
         $error_message = $e->getMessage();
     } catch (Exception $e) {
         $error_message = $e->getMessage();
     }
     $result = new ilCronJobResult();
     if ($error_message) {
         $result->setMessage($error_message);
         $status = ilCronJobResult::STATUS_CRASHED;
     } else {
         $status = ilCronJobResult::STATUS_OK;
     }
     $result->setStatus($status);
     return $result;
 }
Example #13
0
 /**
  * Save job result
  * 
  * @param ilCronJob $a_job
  * @param ilCronJobResult $a_result
  * @param bool $a_manual
  */
 protected static function updateJobResult(ilCronJob $a_job, ilCronJobResult $a_result, $a_manual = false)
 {
     global $ilDB, $ilUser;
     $user_id = $a_manual ? $ilUser->getId() : 0;
     $sql = "UPDATE cron_job SET " . " job_result_status = " . $ilDB->quote($a_result->getStatus(), "integer") . " , job_result_user_id = " . $ilDB->quote($user_id, "integer") . " , job_result_code = " . $ilDB->quote($a_result->getCode(), "text") . " , job_result_message = " . $ilDB->quote($a_result->getMessage(), "text") . " , job_result_type = " . $ilDB->quote($a_manual, "integer") . " , job_result_ts = " . $ilDB->quote(time(), "integer") . " , job_result_dur = " . $ilDB->quote($a_result->getDuration() * 1000, "integer") . " WHERE job_id = " . $ilDB->quote($a_job->getId(), "text");
     $ilDB->manipulate($sql);
 }
 public function run()
 {
     global $lng, $ilDB;
     $status = ilCronJobResult::STATUS_NO_ACTION;
     $status_details = null;
     $setting = new ilSetting("cron");
     $last_run = $setting->get(get_class($this));
     // #10284 - we already did send today, do nothing
     if ($last_run == date("Y-m-d")) {
         // #14005
         $status_details = "Did already run today.";
     } else {
         // gather objects and participants with notification setting
         $objects = array();
         $set = $ilDB->query("SELECT usr_id,keyword FROM usr_pref" . " WHERE " . $ilDB->like("keyword", "text", "grpcrs_ntf_%") . " AND value = " . $ilDB->quote("1", "text"));
         while ($row = $ilDB->fetchAssoc($set)) {
             $ref_id = substr($row["keyword"], 11);
             $type = ilObject::_lookupType($ref_id, true);
             if ($type) {
                 $objects[$type][$ref_id][] = $row["usr_id"];
             }
         }
         $counter = 0;
         if (sizeof($objects)) {
             $old_lng = $lng;
             include_once "Services/News/classes/class.ilNewsItem.php";
             foreach ($objects as $type => $ref_ids) {
                 // type is not needed for now
                 foreach ($ref_ids as $ref_id => $user_ids) {
                     // gather news per object
                     $news_item = new ilNewsItem();
                     if ($news_item->checkNewsExistsForGroupCourse($ref_id)) {
                         foreach ($user_ids as $user_id) {
                             // gather news for user
                             $user_news = $news_item->getNewsForRefId($ref_id, false, false, 1, false, false, false, false, $user_id);
                             if ($user_news) {
                                 $this->sendMail($user_id, $ref_id, $user_news);
                                 $counter++;
                             }
                         }
                     }
                 }
             }
             $lng = $old_lng;
         }
         // save last run
         $setting->set(get_class($this), date("Y-m-d"));
         if ($counter) {
             $status = ilCronJobResult::STATUS_OK;
         }
     }
     $result = new ilCronJobResult();
     $result->setStatus($status);
     if ($status_details) {
         $result->setMessage($status_details);
     }
     return $result;
 }
 public function run()
 {
     global $ilLog;
     $status = ilCronJobResult::STATUS_NO_ACTION;
     $messages = array();
     foreach (ilLDAPServer::_getCronServerIds() as $server_id) {
         try {
             $this->current_server = new ilLDAPServer($server_id);
             $this->current_server->doConnectionCheck();
             $ilLog->write("LDAP: starting user synchronization for " . $this->current_server->getName());
             $this->ldap_query = new ilLDAPQuery($this->current_server);
             $this->ldap_query->bind(IL_LDAP_BIND_DEFAULT);
             if (is_array($users = $this->ldap_query->fetchUsers())) {
                 // Deactivate ldap users that are not in the list
                 $this->deactivateUsers($this->current_server, $users);
             }
             if (count($users)) {
                 $ilLog->write("LDAP: Starting update/creation of users ...");
                 $this->ldap_to_ilias = new ilLDAPAttributeToUser($this->current_server);
                 $this->ldap_to_ilias->setNewUserAuthMode($this->current_server->getAuthenticationMappingKey());
                 #$ilLog->write(print_r($users,true));
                 $this->ldap_to_ilias->setUserData($users);
                 $this->ldap_to_ilias->refresh();
                 $ilLog->write("LDAP: Finished update/creation");
                 $this->counter++;
             } else {
                 $ilLog->write("LDAP: No users for update/create. Aborting.");
             }
         } catch (ilLDAPQueryException $exc) {
             $mess = $exc->getMessage();
             $ilLog->write($mess);
             $messages[] = $mess;
         }
     }
     if ($this->counter) {
         $status = ilCronJobResult::STATUS_OK;
     }
     $result = new ilCronJobResult();
     if (sizeof($messages)) {
         $result->setMessage(implode("\n", $messages));
     }
     $result->setStatus($status);
     return $result;
 }
    public function run()
    {
        global $ilDB, $ilLog, $ilSetting, $lng;
        $status = ilCronJobResult::STATUS_NO_ACTION;
        $lng->loadLanguageModule('forum');
        if (!($last_run_datetime = $ilSetting->get('cron_forum_notification_last_date'))) {
            $last_run_datetime = null;
        }
        $numRows = 0;
        $types = array();
        $values = array();
        if ($last_run_datetime != null && checkDate(date('m', strtotime($last_run_datetime)), date('d', strtotime($last_run_datetime)), date('Y', strtotime($last_run_datetime)))) {
            $threshold = max(strtotime($last_run_datetime), strtotime('-' . (int) $this->settings->get('max_notification_age', 30) . ' days', time()));
        } else {
            $threshold = strtotime('-' . (int) $this->settings->get('max_notification_age', 30) . ' days', time());
        }
        $date_condition = ' frm_posts.pos_date >= %s AND ';
        $types[] = 'timestamp';
        $values[] = date('Y-m-d H:i:s', $threshold);
        $cj_start_date = date('Y-m-d H:i:s');
        /*** FORUMS ***/
        $res = $ilDB->queryf('
			SELECT 	frm_threads.thr_subject thr_subject, 
					frm_data.top_name top_name, 
					frm_data.top_frm_fk obj_id, 
					frm_notification.user_id user_id, 
					frm_posts.* 
			FROM 	frm_notification, frm_posts, frm_threads, frm_data 
			WHERE	' . $date_condition . ' frm_posts.pos_thr_fk = frm_threads.thr_pk
			AND 	frm_threads.thr_top_fk = frm_data.top_pk 
			AND 	frm_data.top_frm_fk = frm_notification.frm_id
			ORDER BY frm_posts.pos_date ASC', $types, $values);
        $numRows += $this->sendMails($res);
        /*** THREADS ***/
        $res = $ilDB->queryf('
			SELECT 	frm_threads.thr_subject thr_subject, 
					frm_data.top_name top_name, 
					frm_data.top_frm_fk obj_id, 
					frm_notification.user_id user_id, 
					frm_posts.* 
			FROM 	frm_notification, frm_posts, frm_threads, frm_data 
			WHERE 	' . $date_condition . ' frm_posts.pos_thr_fk = frm_threads.thr_pk
			AND		frm_threads.thr_pk = frm_notification.thread_id 
			AND 	frm_data.top_pk = frm_threads.thr_top_fk 
			ORDER BY frm_posts.pos_date ASC', $types, $values);
        $numRows += $this->sendMails($res);
        $ilSetting->set('cron_forum_notification_last_date', $cj_start_date);
        $mess = 'Send ' . $numRows . ' messages.';
        $ilLog->write(__METHOD__ . ': ' . $mess);
        $result = new ilCronJobResult();
        if ($numRows) {
            $status = ilCronJobResult::STATUS_OK;
            $result->setMessage($mess);
        }
        $result->setStatus($status);
        return $result;
    }
 public function run()
 {
     global $rbacreview, $ilLog;
     $status = ilCronJobResult::STATUS_NO_ACTION;
     $reminder_time = (int) $this->reminderTimer;
     $checkMail = (int) $this->period - $reminder_time;
     $usr_ids = ilObjUser::_getUserIdsByInactivityPeriod($checkMail);
     $counter = 0;
     $userDeleted = 0;
     $userMailsDelivered = 0;
     foreach ($usr_ids as $usr_id) {
         if ($usr_id == ANONYMOUS_USER_ID || $usr_id == SYSTEM_USER_ID) {
             continue;
         }
         $continue = true;
         foreach ($this->include_roles as $role_id) {
             if ($rbacreview->isAssigned($usr_id, $role_id)) {
                 $continue = false;
                 break;
             }
         }
         if ($continue) {
             continue;
         }
         /**
          * @var $user ilObjUser
          */
         $user = ilObjectFactory::getInstanceByObjId($usr_id);
         $last_login_timestamp = strtotime($user->getLastLogin());
         $grace_period_over = time() - (int) $this->period * 24 * 60 * 60;
         if ($last_login_timestamp < $grace_period_over) {
             $user->delete();
             $userDeleted++;
         } else {
             if ($reminder_time > 0) {
                 $mailSent = ilCronDeleteInactiveUserReminderMail::checkIfReminderMailShouldBeSend($user, $reminder_time);
                 if ($mailSent) {
                     $userMailsDelivered++;
                 }
             }
         }
         $counter++;
     }
     if ($counter) {
         $status = ilCronJobResult::STATUS_OK;
     }
     ilCronDeleteInactiveUserReminderMail::removeEntriesFromTableIfLastLoginIsNewer();
     $ilLog->write("CRON - ilCronDeleteInactiveUserAccounts::run(), deleted => {$userDeleted} User(s), sent reminder mail to {$userMailsDelivered} User(s)");
     $result = new ilCronJobResult();
     $result->setStatus($status);
     return $result;
 }
 public function run()
 {
     global $rbacreview;
     $status = ilCronJobResult::STATUS_NO_ACTION;
     $usr_ids = ilObjUser::_getUserIdsByInactivityPeriod($this->period);
     $counter = 0;
     foreach ($usr_ids as $usr_id) {
         if ($usr_id == ANONYMOUS_USER_ID || $usr_id == SYSTEM_USER_ID) {
             continue;
         }
         $continue = true;
         foreach ($this->include_roles as $role_id) {
             if ($rbacreview->isAssigned($usr_id, $role_id)) {
                 $continue = false;
                 break;
             }
         }
         if ($continue) {
             continue;
         }
         $user = ilObjectFactory::getInstanceByObjId($usr_id);
         $user->delete();
         $counter++;
     }
     if ($counter) {
         $status = ilCronJobResult::STATUS_OK;
     }
     $result = new ilCronJobResult();
     $result->setStatus($status);
     return $result;
 }