소스 검색

command line sync now support bypass, minimum interval 600 seconds

master
patrick 6 년 전
부모
커밋
c5ce7e32fb
2개의 변경된 파일12개의 추가작업 그리고 5개의 파일을 삭제
  1. +7
    -5
      Xero.php
  2. +5
    -0
      ts.php

+ 7
- 5
Xero.php 파일 보기

@@ -71,7 +71,7 @@ class Xero {
//does not work for too many users or employees
public function sync_users(){
$this->sync_clients();
//$this->sync_employees();
$this->sync_employees();
}
private function sync_clients(){
$contacts = $this->getClients($this->clientgroup);
@@ -130,16 +130,18 @@ class Xero {
private function ensure_staff_exists($employee)
{
$login = $employee->getEmployeeID();
$xero_employee = $this->getEmployee($login);
$args = $this->xero_employee_profile($xero_employee);
$user = get_user_by('login', $login);
if ($user === false){
$xero_employee = $this->getEmployee($login);
$args = $this->xero_employee_profile($xero_employee);
$id = wp_insert_user($args);
$user = get_user_by('ID', $id);
}else{
if ($this->is_too_close_to_sync($user)){
return;
}
$xero_employee = $this->getEmployee($login);
$args = $this->xero_employee_profile($xero_employee);
$args['ID'] = $user->ID;
unset($args['user_pass']);
wp_update_user($args);
@@ -175,9 +177,9 @@ class Xero {
$lastsync = $this->get_last_sync($user->ID);
$now = time();
$diff = $now - (int) $lastsync;
echo "lastsync = $lastsync, now = $now , diff = $diff; \n" ;
if ($diff < $this->minimum_sync_interval_in_seconds){
$msg = sprintf("SKIP sync user %d, login=%s, display_name=%s\n", $user->ID, $user->user_login, $user->display_name);
$msg = sprintf("\tSKIP userid(%d),login=%s,display_name=%s,(lastsync=%d secs ago, mininterval=%d) \n",
$user->ID, $user->user_login, $user->display_name, $diff, $this->minimum_sync_interval_in_seconds);
$this->logConsole($msg);
return true;
}

+ 5
- 0
ts.php 파일 보기

@@ -91,6 +91,11 @@ class AcareOffice{
wp_enqueue_script( 'bts_ts', plugins_url('js/bts_timesheet.js', __FILE__), array( 'jquery' , 'bts' ));
}
public function sync_users()
{
$a=1;
return;
}
public function sync_user_cli($args = array(), $assoc_args = array()){
$this->cli = true;
echo "running sync user from command line;\n";

Loading…
취소
저장