public function listing() { $role = $this->fetchParam('role', false); $limit = $this->fetchParam('limit', null, 'is_numeric'); // defaults to none $offset = $this->fetchParam('offset', 0, 'is_numeric'); // defaults to zero $sort_by = $this->fetchParam('sort_by', 'title'); // defaults to date $sort_dir = $this->fetchParam('sort_dir', 'desc'); // defaults to desc $members = Statamic_Auth::get_user_list(false); if (is_array($members) && count($members) > 0) { $members = array_slice($members, $offset, $limit, true); if ($sort_by == 'random') { shuffle($list); } elseif ($sort_by != 'title' || $sort_by != 'username') { # sort by any other field usort($members, function ($a, $b) use($sort_by) { if (isset($a[$sort_by]) && isset($b[$sort_by])) { return strcmp($b[$sort_by], $a[$sort_by]); } }); } // default sort is asc if ($sort_dir == 'desc') { $members = array_reverse($members); } return Parse::tagLoop($this->content, $members); } else { return array('no_results' => true); } }
/** * The Routes **/ function authenticateForRole($role = 'member') { $admin_app = \Slim\Slim::getInstance(); $user = Statamic_Auth::get_current_user(); if ($user) { if ($user->has_role($role) === false) { $admin_app->redirect($admin_app->urlFor('denied')); } } else { $admin_app->redirect($admin_app->urlFor('login')); } return true; }
public function redactor__fetch_images() { if (!Statamic_Auth::get_current_user()) { exit("Invalid Request"); } $dir = Path::tidy(ltrim(Request::get('path'), '/') . '/'); $image_list = glob($dir . "*.{jpg,jpeg,gif,png}", GLOB_BRACE); $images = array(); if (count($image_list) > 0) { foreach ($image_list as $image) { $images[] = array('thumb' => Config::getSiteRoot() . $image, 'image' => Config::getSiteRoot() . $image); } } echo json_encode($images); }
public function render() { $html = "<div class='input-select-wrap'><select name='{$this->fieldname}' tabindex='{$this->tabindex}'>"; $html .= "<option value=''>- None Selected-</option>"; $current_user = Statamic_Auth::get_current_user(); $current_username = $current_user->get_name(); if ($this->field_data == '') { $this->field_data = $current_username; } foreach (Statamic_Auth::get_user_list() as $key => $data) { $selected = $this->field_data == $key ? " selected='selected'" : ''; $html .= "<option {$selected} value='{$key}'>{$data->get_first_name()} {$data->get_last_name()}</option>"; } $html .= "</select></div>"; return $html; }
/** * Set up any and all global vars, tags, and other defaults * * @return void */ public static function setDefaultTags() { $app = \Slim\Slim::getInstance(); /* |-------------------------------------------------------------------------- | User & Session Authentication |-------------------------------------------------------------------------- | | This may be overwritten later, but let's go ahead and set the default | layout file to start assembling our front-end view. | */ $current_user = Statamic_Auth::get_current_user(); $app->config['logged_in'] = $current_user !== FALSE; $app->config['username'] = $current_user ? $current_user->get_name() : FALSE; $app->config['is_admin'] = $current_user ? $current_user->has_role('admin') : FALSE; /** * @deprecated * The {{ user }} tag has been replaced by {{ member:profile }} and * will be removed in v1.6 */ $app->config['user'] = $current_user ? array(array('first_name' => $current_user->get_first_name()), array('last_name' => $current_user->get_last_name()), array('bio' => $current_user->get_biography())) : FALSE; $app->config['homepage'] = Config::getSiteRoot(); /* |-------------------------------------------------------------------------- | Load Environment Configs and Variables |-------------------------------------------------------------------------- | | Environments settings explicitly overwrite any existing settings, and | therefore must be loaded late. We also set a few helper variables | to make working with environments even easier. | */ Environment::establish(); }
<?php $current_user = Statamic_Auth::get_current_user(); $name = $current_user->get_name(); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"> <title>Statamic Control Panel</title> <link rel="stylesheet" href="<?php echo Path::tidy(Config::getSiteRoot() . '/' . $app->config['theme_path']); ?> css/ascent.min.css"> <link rel="shortcut icon" href="<?php print Path::tidy(Config::getSiteRoot() . '/' . $app->config['theme_path']); ?> img/favicon.ico" /> <script type="text/javascript" src="<?php echo Path::tidy(Config::getSiteRoot() . '/' . $app->config['theme_path']); ?> js/ascent.min.js"></script> <?php echo Hook::run('control_panel', 'add_to_head', 'cumulative'); ?> </head> <body id="<?php echo $route; ?> ">
public function member__logout() { $return = Request::get('return', Config::getSiteRoot()); Statamic_Auth::logout(); URL::redirect(URL::assemble(Config::getSiteRoot(), $return)); }