public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $locale = FWS_Props::get()->locale();
     $project_name = $input->get_var('project_name', 'post', FWS_Input::STRING);
     $project_name_short = $input->get_var('project_name_short', 'post', FWS_Input::STRING);
     $start_day = $input->get_var('start_day', 'post', FWS_Input::INTEGER);
     $start_month = $input->get_var('start_month', 'post', FWS_Input::INTEGER);
     $start_year = $input->get_var('start_year', 'post', FWS_Input::INTEGER);
     $start = mktime(0, 0, 0, $start_month, $start_day, $start_year);
     $project = new TDL_Objects_Project(TDL_TB_PROJECTS);
     $project->set_project_name($project_name);
     $project->set_project_name_short($project_name_short);
     $project->set_project_start($start);
     if (!$project->check('create')) {
         return $project->errors();
     }
     $project->create();
     $id = $project->get_id();
     $edit_url = TDL_URL::get_mod_url('edit_project')->set(TDL_URL_MODE, 'edit')->set(TDL_URL_ID, $id);
     $this->set_success_msg($locale->_('The project has been added'));
     $this->set_redirect(true, $edit_url);
     $this->add_link($locale->_('Edit the project'), $edit_url);
     $this->set_action_performed(true);
     return '';
 }
Esempio n. 2
0
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $locale = FWS_Props::get()->locale();
     $id_str = $input->get_predef(TDL_URL_IDS, 'get');
     $ids = FWS_Array_Utils::advanced_explode(',', $id_str);
     if (!FWS_Array_Utils::is_numeric($ids) || count($ids) == 0) {
         return TDL_GENERAL_ERROR;
     }
     foreach ($ids as $id) {
         $project = new TDL_Objects_Project(TDL_TB_PROJECTS);
         $project->set_id($id);
         if (!$project->check('delete')) {
             return $project->errors();
         }
         $project->delete();
     }
     $this->set_success_msg($locale->_('The projects have been deleted'));
     $this->set_redirect(true, TDL_URL::get_mod_url('view_projects'));
     $this->add_link($locale->_('Back'), TDL_URL::get_mod_url('view_projects'));
     $this->set_action_performed(true);
     return '';
 }
 public function perform_action()
 {
     $input = FWS_Props::get()->input();
     $db = FWS_Props::get()->db();
     $cats = FWS_Props::get()->cats();
     $versions = FWS_Props::get()->versions();
     $locale = FWS_Props::get()->locale();
     $pid = $input->get_predef(TDL_URL_ID, 'get');
     if ($pid == null) {
         return TDL_GENERAL_ERROR;
     }
     $project_name = $input->get_var('project_name', 'post', FWS_Input::STRING);
     $project_name_short = $input->get_var('project_name_short', 'post', FWS_Input::STRING);
     $start_day = $input->get_var('start_day', 'post', FWS_Input::INTEGER);
     $start_month = $input->get_var('start_month', 'post', FWS_Input::INTEGER);
     $start_year = $input->get_var('start_year', 'post', FWS_Input::INTEGER);
     $start = mktime(0, 0, 0, $start_month, $start_day, $start_year);
     $project = new TDL_Objects_Project(TDL_TB_PROJECTS);
     $project->set_id($pid);
     $project->set_project_name($project_name);
     $project->set_project_name_short($project_name_short);
     $project->set_project_start($start);
     if (!$project->check('update')) {
         return $project->errors();
     }
     $project->update();
     $nversions = $input->get_var('version', 'post');
     if (is_array($nversions)) {
         foreach ($nversions as $id => $version_name) {
             $db->execute('UPDATE ' . TDL_TB_VERSIONS . " SET version_name = '" . $version_name . "' WHERE id = " . $id);
             $versions->set_element_field($id, 'version_name', $version_name);
         }
     }
     $categories = $input->get_var('category', 'post');
     if (is_array($categories)) {
         foreach ($categories as $id => $category_name) {
             $db->execute('UPDATE ' . TDL_TB_CATEGORIES . " SET category_name = '" . $category_name . "' WHERE id = " . $id);
             $cats->set_element_field($id, 'category_name', $category_name);
         }
     }
     $this->set_success_msg($locale->_('The project has been edited successfully'));
     $this->set_redirect(true, TDL_URL::get_mod_url('edit_project')->set(TDL_URL_MODE, 'edit')->set(TDL_URL_ID, $pid));
     $this->set_show_status_page(false);
     $this->set_action_performed(true);
     return '';
 }