예제 #1
0
 public function bulk_translate($project_path)
 {
     $project_path = urldecode($project_path);
     $url = gp_url_project($project_path);
     // If we don't have rights, just redirect back to the project.
     if (!GP::$user->current()->can('write', 'project')) {
         gp_redirect($url);
     }
     // Create a project class to use to get the project object.
     $project_class = new GP_Project();
     // Get the project object from the project path that was passed in.
     $project_obj = $project_class->by_path($project_path);
     // Get the translations sets from the project ID.
     $translation_sets = GP::$translation_set->by_project_id($project_obj->id);
     // Loop through all the sets.
     foreach ($translation_sets as $set) {
         //Array ( [action] => gtranslate [priority] => 0 [redirect_to] => http://localhost/wp40/gp/projects/sample/bg/my [row-ids] => Array ( [0] => 1 [1] => 2 ) )
         $bulk = array('action' => 'gtranslate', 'priority' => 0, 'row-ids' => array());
         $translation = new GP_Translation();
         $strings = $translation->for_translation($project_obj, $set, null, array('status' => 'untranslated'));
         foreach ($strings as $string) {
             $bulk['row-ids'][] .= $string->row_id;
         }
         $locale = GP_Locales::by_slug($set->locale);
         $this->gp_translation_set_bulk_action_post($project_obj, $locale, $set, $bulk);
     }
     $url = gp_url_project($project_path);
     gp_redirect($url);
 }
예제 #2
0
 public function plugins_loaded()
 {
     // Check to see if we're connected via https, if not, redirect.
     if (!is_ssl()) {
         gp_redirect(gp_url_ssl(gp_url_current()));
     }
 }
예제 #3
0
 function new_post()
 {
     $new_set = new GP_Translation_Set(gp_post('set'));
     if ($new_set->project_id) {
         $this->can_or_redirect('write', 'project', $new_set->project_id, gp_url_project(GP::$project->get($new_set->project_id)));
     } else {
         $this->can_or_redirect('write', 'project', null, gp_url_project(''));
     }
     $this->validate_or_redirect($new_set, gp_url('/sets/_new', array('project_id' => $new_set->project_id)));
     $set = GP::$translation_set->create_and_select($new_set);
     $project = GP::$project->get($set->project_id);
     if (!$set) {
         $this->errors[] = __('Error in creating translation set!');
         gp_redirect(gp_url('/sets/_new', array('project_id' => $new_set['project_id'])));
     } else {
         $this->notices[] = __('The translation set was created!');
         gp_redirect(gp_url_project_locale($project, $set->locale, $set->slug));
     }
 }
예제 #4
0
파일: index.php 프로젝트: rmccue/GlotPress
 function index()
 {
     gp_redirect(gp_url_project(''));
 }
예제 #5
0
 function new_post()
 {
     $post = gp_post('project');
     $parent_project_id = gp_array_get($post, 'parent_project_id', null);
     $this->can_or_redirect('write', 'project', $parent_project_id);
     $new_project = new GP_Project($post);
     $this->validate_or_redirect($new_project);
     $project = GP::$project->create_and_select($new_project);
     if (!$project) {
         $project = new GP_Project();
         $this->errors[] = __('Error in creating project!');
         $all_project_options = self::_options_from_projects(GP::$project->all());
         gp_tmpl_load('project-new', get_defined_vars());
     } else {
         $this->notices[] = __('The project was created!');
         gp_redirect(gp_url_project($project, '_edit'));
     }
 }
예제 #6
0
 function permissions_delete($project_path, $locale_slug, $translation_set_slug, $permission_id)
 {
     $project = GP::$project->by_path($project_path);
     $locale = GP_Locales::by_slug($locale_slug);
     $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug);
     if (!$project || !$locale || !$translation_set) {
         gp_tmpl_404();
     }
     $this->can_or_redirect('write', 'project', $project->id);
     $permission = GP::$permission->get($permission_id);
     if ($permission) {
         if ($permission->delete()) {
             $this->notices[] = 'Permissin was deleted.';
         } else {
             $this->errors[] = 'Error in deleting permission!';
         }
     } else {
         $this->errors[] = 'Permission wasn’t found!';
     }
     gp_redirect(gp_url_project($project, array($locale->slug, $translation_set->slug, '_permissions')));
 }
예제 #7
0
파일: routes.php 프로젝트: rmccue/GlotPress
 function _redirect($url = null)
 {
     // TODO: do not redirect to projects, but to /
     // currently it goes to /projects, because / redirects too and the notice is gone
     if (is_null($url)) {
         $url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : gp_url('/projects');
     }
     gp_redirect($url);
     exit;
 }
예제 #8
0
파일: login.php 프로젝트: rmccue/GlotPress
 function logout()
 {
     GP::$user->logout();
     gp_redirect(gp_url('/'));
 }
예제 #9
0
 function redirect($url = null)
 {
     if ($this->fake_request) {
         $this->redirected = true;
         $this->redirected_to = $url;
         return;
     }
     $this->set_notices_and_errors();
     // TODO: do not redirect to projects, but to /
     // currently it goes to /projects, because / redirects too and the notice is gone
     if (is_null($url)) {
         $url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : gp_url('/projects');
     }
     gp_redirect($url);
     $this->tmpl('redirect', compact('url'));
 }