Example #1
0
 private function getProjectData($action = null)
 {
     $id_project = (int) Tools::getValue('id_project');
     $project_obj = new TextMasterProject((int) $id_project);
     $project_data = $project_obj->getProjectData();
     $configuration = new TextMasterConfiguration();
     $ctypes = array('translation', 'proofreading', 'copywriting');
     $results = array();
     foreach ($ctypes as $ctype => $ctype_value) {
         foreach ($configuration->getData() as $item => $item_value) {
             if (strpos($item, $ctype_value) !== false) {
                 $results[$item] = $item_value;
             }
         }
     }
     $results['project_step'] = 'summary';
     $results['project_name'] = isset($project_data['name']) ? $project_data['name'] : '';
     $results['ctype'] = isset($project_data['ctype']) ? $project_data['ctype'] : 'translation';
     foreach ($results as $result => $result_value) {
         foreach ($project_data as $item => $item_value) {
             if ($result == $results['ctype'] . '_' . $item) {
                 $results[$result] = $item_value;
             }
         }
     }
     $selected_products = DB::getInstance()->executeS("\n\t\t\tSELECT `id_product`\n\t\t\tFROM `" . _DB_PREFIX_ . "textmaster_document`\n\t\t\tWHERE `id_project` = '" . (int) $id_project . "'\n\t\t\tGROUP BY `id_product`\n\t\t");
     $selected_names = DB::getInstance()->executeS("\n\t\t\tSELECT `name`\n\t\t\tFROM `" . _DB_PREFIX_ . "textmaster_document`\n\t\t\tWHERE `id_project` = '" . (int) $id_project . "'\n\t\t\tGROUP BY `name`\n\t\t");
     if (!$selected_products) {
         $selected_products = array();
     }
     if (!$selected_names) {
         $selected_names = array();
     }
     $selected_products_array = array();
     $selected_names_array = array();
     foreach ($selected_products as $product => $id) {
         $selected_products_array[] = $id['id_product'];
     }
     foreach ($selected_names as $name => $value) {
         $selected_names_array[] = $value['name'];
     }
     if (!empty($selected_products_array)) {
         $results['selected_products_ids'] = $selected_products_array;
     }
     $additional_info = '';
     if ($action == 'updateproject') {
         $results['id_edit_project'] = (int) $id_project;
         $additional_info = '&editTextmasterProject&id_project=' . (int) $id_project;
     }
     $textmasters = array();
     if (isset($project_data['textmasters']) && !empty($project_data['textmasters'])) {
         foreach ($project_data['textmasters'] as $textmaster) {
             $textmasters[] = $textmaster['author_id'];
         }
         $results['authors'] = $textmasters;
     }
     $results['restrict_to_textmasters'] = (int) isset($project_data['authors']);
     $results[$project_data['ctype'] . '_expertise_on'] = (int) isset($project_data['options']['expertise']);
     $results[$project_data['ctype'] . '_language_level'] = $project_data['options']['language_level'];
     $results[$project_data['ctype'] . '_quality_on'] = (int) isset($project_data['options']['quality']);
     $this->addFlashWarning($this->l('Please reselect TextMasters for this project'));
     $textmasterAPI = $this->getAPIConnection();
     $this->checkLanguages($results[$project_data['ctype'] . '_language_from'], $textmasterAPI->getLanguages());
     if ($project_data['ctype'] == 'translation') {
         $this->checkLanguages($results[$project_data['ctype'] . '_language_to'], $textmasterAPI->getLanguages());
     }
     $results['project_data'] = $selected_names_array;
     $this->textmaster_data_with_cookies_manager_obj->setAllProject($results);
     Tools::redirectAdmin(self::CURRENT_INDEX . Tools::getValue('token') . '&configure=' . $this->name . $additional_info . '&menu=create_project&step=products&token=' . Tools::getAdminTokenLite('AdminModules'));
 }