Esempio n. 1
0
 private function init_job()
 {
     $this->job = false;
     $this->translator_has_job_language_pairs = false;
     $this->user_can_take_this_job = false;
     $this->job_id = WPML_Translation_Editor::get_job_id_from_request();
     if ($this->job_id) {
         WPML_Translation_Job_Terms::set_translated_term_values($this->job_id);
         $this->job = $this->sitepressTM->get_translation_job($this->job_id, false, true, 1);
         if ($this->job) {
             $this->user_can_take_this_job = $this->job->translator_id == 0 || $this->job->translator_id == $this->current_user->ID;
             $this->job_language_pairs = array('lang_from' => $this->job->source_language_code, 'lang_to' => $this->job->language_code);
             $this->translator_has_job_language_pairs = $this->sitepressTM->is_translator($this->current_user->ID, $this->job_language_pairs);
         }
     }
     $this->is_valid_job = !$this->job || (!$this->user_can_take_this_job || !$this->translator_has_job_language_pairs) && !current_user_can('manage_options');
 }
Esempio n. 2
0
<?php

require_once WPML_TM_PATH . '/menu/wpml-translation-editor-ui.class.php';
/**
 * @var TranslationManagement $iclTranslationManagement
 * @var WPML_Translation_Job_Factory $wpml_translation_job_factory
 */
global $wp_query, $sitepress, $iclTranslationManagement, $current_user, $wpml_translation_job_factory;
if (!isset($job_checked) && (isset($_GET['job_id']) && $_GET['job_id'] > 0 || isset($_GET['trid']) && $_GET['trid'] > 0)) {
    $job_id = WPML_Translation_Editor::get_job_id_from_request();
    $job_object = $wpml_translation_job_factory->get_translation_job($job_id, false, 0, true);
    if (is_a($job_object, 'WPML_Post_Translation_Job')) {
        /** @var WPML_Post_Translation_Job $job_object */
        $job_object->load_terms_from_post_into_job();
    }
    if ($job_object && $job_object->user_can_translate($current_user)) {
        $translation_editor_ui = new WPML_Translation_Editor_UI($sitepress, $iclTranslationManagement, $job_object);
        $translation_editor_ui->render();
        return;
    }
}
if (!empty($_GET['resigned'])) {
    $iclTranslationManagement->add_message(array('type' => 'updated', 'text' => __("You've resigned from this job.", 'wpml-translation-management')));
}
if (isset($_SESSION['translation_ujobs_filter'])) {
    $icl_translation_filter = $_SESSION['translation_ujobs_filter'];
}
$current_translator = $iclTranslationManagement->get_current_translator();
$can_translate = $current_translator && $current_translator->ID > 0 && $current_translator->language_pairs;
$post_link_factory = new WPML_TM_Post_Link_Factory($sitepress);
if ($can_translate) {