Ejemplo n.º 1
0
 function sync_from_API($mode = '')
 {
     global $beanFiles;
     require_once $beanFiles['TILKEE_PROJECTS'];
     $associated_project = new TILKEE_PROJECTS();
     $projects_array = $this->get_linked_beans('tilkee_projects_tilkee_tilks', 'TILKEE_PROJECTS');
     $tilkee_project_id = 0;
     foreach ($projects_array as $project) {
         $tilkee_project_id = $project->tilkee_id;
     }
     if (!empty($tilkee_project_id)) {
         require_once 'custom/include/externalAPI/Tilkee/ExtAPITilkee.php';
         $tilkee = new ExtAPITilkee();
         $result = $tilkee->infos_tilk($tilkee_project_id, $this->tilkee_id);
         if ($result != -1 && !empty($result)) {
             // project updated : init bean
             $this->name = $result->title;
             $this->tilk_url = $result->url;
             $this->won = $result->won == 1 ? 'true' : 'false';
             $this->archived = !empty($result->archived_at) ? 'true' : 'false';
             $this->created_at = !empty($result->created_at) ? date('Y-m-d H:i:s', strtotime($result->created_at)) : '';
             $this->archived_at = !empty($result->archived_at) ? date('Y-m-d H:i:s', strtotime($result->archived_at)) : '';
             $this->last_sign_in_at = !empty($result->last_sign_in_at) ? date('Y-m-d H:i:s', strtotime($result->last_sign_in_at)) : '';
             $this->total_time = $this->convert_time($result->total_time);
             $this->total_connexion = $result->total_connexion;
             $this->save();
             // UPDATE LINKED CONNEXIONS
             if ($mode == 'update_connexions') {
                 global $beanFiles;
                 require_once $beanFiles['TILKEE_CONNEXIONS'];
                 $cur_connexions = new TILKEE_CONNEXIONS();
                 $cur_connexions->updateFromArray($this->id, $result->connexions);
             }
         } else {
             global $mod_strings;
             SugarApplication::appendErrorMessage($mod_strings['LBL_ERROR_SYNC_ON_TILKEE']);
             $GLOBALS['log']->fatal('TILKS sync_from_API -> ERROR RETRIEVE TILK INFOS FOR TILK : ' . $this->tilkee_id . ' - PROJECT : ' . $associated_project->tilkee_id);
         }
     }
     return 0;
 }
Ejemplo n.º 2
0
 function sync_from_API($mode = '')
 {
     if (!empty($this->tilkee_id)) {
         require_once 'custom/include/externalAPI/Tilkee/ExtAPITilkee.php';
         $tilkee = new ExtAPITilkee();
         $result = $tilkee->infos_project($this->tilkee_id);
         if ($result != -1 && !empty($result)) {
             // project created : init bean
             $this->set_result_to_bean($result);
             // Create or update tilks from return data
             if ($mode == 'update_tilks') {
                 global $beanFiles;
                 require_once $beanFiles['TILKEE_TILKS'];
                 $cur_tilks = new TILKEE_TILKS();
                 $cur_tilks->updateFromArray($this->id, $result->tilks);
             }
             // TBD
         } else {
             global $mod_strings;
             SugarApplication::appendErrorMessage($mod_strings['LBL_ERROR_UPDATE_ON_TILKEE']);
         }
     }
 }
Ejemplo n.º 3
0
 function delete_tilkee_project(&$bean, $event, $arguments = null)
 {
     if ($event != 'before_delete') {
         return;
     }
     // appel de l'API de suppression du projet
     require_once 'custom/include/externalAPI/Tilkee/ExtAPITilkee.php';
     $tilkee = new ExtAPITilkee();
     $result = $tilkee->delete_project($this->tilkee_id);
     // No return info from the API so we expect it's realy deleted !!!
     // And delete linked tilks
     $bean->load_relationship('tilkee_projects_tilkee_tilks');
     foreach ($bean->tilkee_projects_tilkee_tilks->getBeans() as $tilkee_tilks) {
         $tilkee_tilks->mark_deleted($tilkee_tilks->id);
     }
 }
Ejemplo n.º 4
0
global $current_user, $sugar_config;
if (!is_admin($current_user)) {
    sugar_die("Unauthorized access to administration.");
}
require_once 'modules/Configurator/Configurator.php';
echo getClassicModuleTitle("Administration", array("<a href='index.php?module=Administration&action=index'>" . translate('LBL_MODULE_NAME', 'Administration') . "</a>", $mod_strings['LBL_CONFIG_TITLE']), false);
$cfg = new Configurator();
$sugar_smarty = new Sugar_Smarty();
$errors = array();
///////////////////////////////////////////////////////////////////////////////
////	HANDLE CHANGES
$display_result = '';
$display_title = '';
if (isset($_REQUEST['process']) && $_REQUEST['process'] == 'true') {
    require_once 'custom/include/externalAPI/Tilkee/ExtAPITilkee.php';
    $tilkee = new ExtAPITilkee();
    switch ($_REQUEST['test_action']) {
        case 'test_token':
            $result = $tilkee->get_token_access();
            $display_result = print_r($result, true);
            $display_title = "Token Test";
            break;
        case 'test_connexion':
            $result = $tilkee->init_tilkee_access_eapm();
            $display_result = print_r($result, true);
            $display_title = "Connection Test";
            break;
        case 'infos_project':
            if ($_REQUEST['project_id_infos_project'] != '') {
                $result = $tilkee->infos_project($_REQUEST['project_id_infos_project']);
                $display_result = print_r($result, true);