Esempio n. 1
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()));
     }
 }
Esempio n. 2
0
function gp_nav_menu_items($location = 'main')
{
    $items = array();
    if ('main' === $location) {
        $items[gp_url('/projects')] = __('Projects', 'glotpress');
        $items[gp_url('/languages')] = __('Locales', 'glotpress');
    } elseif ('side' === $location) {
        if (is_user_logged_in()) {
            $items[gp_url('/profile')] = __('Profile', 'glotpress');
            $items[esc_url(wp_logout_url(gp_url_current()))] = __('Log out', 'glotpress');
        } else {
            $items[esc_url(wp_login_url(gp_url_current()))] = __('Log in', 'glotpress');
        }
    }
    return apply_filters('gp_nav_menu_items', $items, $location);
}
        ?>
</span>
			<span class="user"><?php 
        echo esc_html($permission->locale_slug);
        ?>
</span>
			<span class="permission-action"><?php 
        _e('and slug');
        ?>
</span>
			<span class="user"><?php 
        echo esc_html($permission->set_slug);
        ?>
</span>
			<a href="<?php 
        echo gp_url_join(gp_url_current(), '-delete/' . $permission->id);
        ?>
" class="action delete"><?php 
        _e('Remove');
        ?>
</a>
		</li>
	<?php 
    }
    ?>
</ul>
	<?php 
}
?>
	<?php 
if ($parent_permissions) {
Esempio n. 4
0
	<?php 
    if ($can_write) {
        ?>
	<select name="bulk[priority]" id="bulk-priority">
	<?php 
        foreach (GP::$original->get_static('priorities') as $value => $label) {
            $selected = $value == 'normal' ? " selected='selected'" : '';
            echo "\t<option value='" . esc_attr($value) . "' {$selected}>" . esc_html($label) . "</option>\n";
        }
        ?>
	</select>
	<?php 
    }
    ?>
	<input type="hidden" name="bulk[redirect_to]" value="<?php 
    echo esc_attr(gp_url_current());
    ?>
" id="bulk[redirect_to]" />
	<input type="hidden" name="bulk[row-ids]" value="" id="bulk[row-ids]" />
	<input type="submit" class="button" value="<?php 
    esc_attr_e('Apply', 'glotpress');
    ?>
" />
	</div>
</form>
<?php 
}
echo gp_pagination($page, $per_page, $total_translations_count);
?>
<form id="upper-filters-toolbar" class="filters-toolbar" action="" method="get" accept-charset="utf-8">
	<div>
Esempio n. 5
0
<?php

gp_title(sprintf(__('Branch Project %s &lt; GlotPress', 'glotpress'), $project->name));
gp_breadcrumb_project($project);
gp_tmpl_header();
?>
<h2><?php 
echo wptexturize(sprintf(__('Branch project "%s"', 'glotpress'), esc_html($project->name)));
?>
</h2>
<p><?php 
_e('Here you can branch out this project: everything will be duplicated into a new project for you.', 'glotpress');
?>
</p>
<form action="<?php 
echo esc_url(gp_url_current());
?>
" method="post">
	<dt><label for="project[name]"><?php 
_e('New branch name', 'glotpress');
?>
</label></dt>
	<dd><input type="text" name="project[name]" value="" placeholder="type tag project name here" id="project[name]"></dd>

	<!-- TODO: make slug edit WordPress style -->
	<dt><label for="project[slug]"><?php 
_e('New Slug', 'glotpress');
?>
</label></dt>
	<dd>
		<input type="text" name="project[slug]" value="" id="project[slug]">
Esempio n. 6
0
 function test_gp_url_current_should_return_non_standard_port_url()
 {
     $server_vars = $_SERVER;
     $_SERVER['HTTPS'] = 0;
     $_SERVER['HTTP_HOST'] = 'glotpress.org:8888';
     $_SERVER['REQUEST_URI'] = '/';
     $_SERVER['SERVER_PORT'] = 8888;
     $this->assertEquals('http://glotpress.org:8888/', gp_url_current());
     $_SERVER = $server_vars;
 }
Esempio n. 7
0
 public function permissions_post($project_path)
 {
     $project = GP::$project->by_path($project_path);
     if (!$project) {
         return $this->die_with_404();
     }
     if ($this->cannot_and_redirect('write', 'project', $project->id)) {
         return;
     }
     if ('add-validator' == gp_post('action')) {
         $user = get_user_by('login', gp_post('user_login'));
         if (!$user) {
             $this->redirect_with_error(__('User wasn&#8217;t found!', 'glotpress'), gp_url_current());
             return;
         }
         $new_permission = new GP_Validator_Permission(array('user_id' => $user->ID, 'action' => 'approve', 'project_id' => $project->id, 'locale_slug' => gp_post('locale'), 'set_slug' => gp_post('set-slug')));
         if ($this->invalid_and_redirect($new_permission, gp_url_current())) {
             return;
         }
         $permission = GP::$validator_permission->create($new_permission);
         $permission ? $this->notices[] = __('Validator was added.', 'glotpress') : ($this->errors[] = __('Error in adding validator.', 'glotpress'));
     }
     $this->redirect(gp_url_current());
 }
Esempio n. 8
0
		<tbody>
		<?php 
foreach ($locales as $locale) {
    ?>
			<tr class="<?php 
    echo $parity();
    ?>
">
				<?php 
    echo "<td>" . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->english_name) . "</td>";
    ?>
				<?php 
    echo "<td>" . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->native_name) . "</td>";
    ?>
				<?php 
    echo "<td>" . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->slug) . "</td>";
    ?>
			</tr>
		<?php 
}
?>
		</tbody>
	</table>

	<script type="text/javascript" charset="utf-8">
		jQuery(document).ready(function($) {
			$('.locales').tablesorter({
				headers: {
					0: {
						sorter: 'text'
					}
Esempio n. 9
0
        ?>
</td>
					<td><?php 
        echo esc_html($permission->action);
        ?>
</td>
					<td><?php 
        echo esc_html($permission->locale_slug);
        ?>
</td>
					<td><?php 
        echo esc_html($permission->set_slug);
        ?>
</td>
					<td><a href="<?php 
        echo esc_url(gp_route_nonce_url(gp_url_join(gp_url_current(), '-delete/' . $permission->id), 'delete-project-permission_' . $permission->id));
        ?>
" class="action delete"><?php 
        _e('Delete', 'glotpress');
        ?>
</a></td>
				</tr>
			<?php 
    }
    ?>
		</tbody>
	</table>
	<?php 
}
?>
	<?php 
Esempio n. 10
0
function gp_nav_menu_items($location = 'main')
{
    $items = array();
    if ('main' === $location) {
        $items[gp_url('/projects')] = __('Projects', 'glotpress');
        $items[gp_url('/languages')] = __('Locales', 'glotpress');
    } elseif ('side' === $location) {
        if (is_user_logged_in()) {
            $items[gp_url('/profile')] = __('Profile', 'glotpress');
            $items[esc_url(wp_logout_url(gp_url_current()))] = __('Log out', 'glotpress');
        } else {
            $items[esc_url(wp_login_url(gp_url_current()))] = __('Log in', 'glotpress');
        }
    }
    /**
     * Filter the list of navigation menu items.
     *
     * @since 1.0.0
     *
     * @param array  $items    Menu items. URL as the key, menu label as the value.
     * @param string $location Location of the menu.
     */
    return apply_filters('gp_nav_menu_items', $items, $location);
}
Esempio n. 11
0
 function permissions_post($project_path, $locale_slug, $translation_set_slug)
 {
     $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);
     if ('add-approver' == gp_post('action')) {
         $user = GP::$user->by_login(gp_post('user_login'));
         if ($user) {
             $res = GP::$permission->create(array('user_id' => $user->id, 'action' => 'approve', 'object_type' => 'translation-set', 'object_id' => $translation_set->id));
             $res ? $this->notices[] = 'Validator was added.' : ($this->errors[] = 'Error in adding validator.');
         } else {
             $this->errors[] = 'User wasn&#8217;t found!';
         }
     }
     gp_redirect(gp_url_current());
 }
Esempio n. 12
0
<?php

gp_title(sprintf(__('%s &lt; GlotPress'), __('Login')));
gp_breadcrumb(array(__('Login')));
gp_tmpl_header();
?>

		<form action="<?php 
echo gp_url_ssl(gp_url_current());
?>
" method="post" class="form-signin" role="form">
			<h2 class="form-signin-heading"><?php 
_e('Login');
?>
</h2>

			<?php 
do_action('before_login_form');
?>

			<input name="user_login" type="text" class="form-control" placeholder="<?php 
_e('Username');
?>
" required="" autofocus="">
			<input name="user_pass" type="password" class="form-control" placeholder="<?php 
_e('Password');
?>
" required="">

			<input type="hidden" value="<?php 
echo esc_attr(gp_get('redirect_to'));
Esempio n. 13
0
foreach ($locales as $locale) {
    $class = 'odd' === $class ? 'even' : 'odd';
    ?>
			<tr class="<?php 
    echo $class;
    // WPCS: XSS ok.
    ?>
">
				<?php 
    echo '<td>' . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->english_name) . '</td>';
    ?>
				<?php 
    echo '<td>' . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->native_name) . '</td>';
    ?>
				<?php 
    echo '<td>' . gp_link_get(gp_url_join(gp_url_current(), $locale->slug), $locale->slug) . '</td>';
    ?>
			</tr>
		<?php 
}
?>
		</tbody>
	</table>

	<script type="text/javascript" charset="utf-8">
		jQuery(document).ready(function($) {
			$('.locales').tablesorter({
				theme: 'glotpress',
				sortList: [[0,0]],
				headers: {
					0: {
Esempio n. 14
0
function gp_url_login($redirect_to = null)
{
    return gp_url('/login', array('redirect_to' => $redirect_to ? $redirect_to : gp_url_current()));
}