本文整理汇总了PHP中BaseController::get_user_logged_in方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseController::get_user_logged_in方法的具体用法?PHP BaseController::get_user_logged_in怎么用?PHP BaseController::get_user_logged_in使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseController
的用法示例。
在下文中一共展示了BaseController::get_user_logged_in方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_if_admin
function check_if_admin()
{
$user = BaseController::get_user_logged_in();
if (!$user->admin) {
Redirect::to('/', array('error' => 'Toiminto on tarkoitettu vain sivuston ylläpitäjälle'));
}
}
示例2: make
public static function make($view, $content = array())
{
// Alustetaan Twig
$twig = self::get_twig();
$rendered_page = "";
$twig->addFilter(new Twig_SimpleFilter('cast_to_array', function ($stdClassObject) {
$response = array();
foreach ($stdClassObject as $key => $value) {
$response[] = array($key, $value);
}
return $response;
}));
try {
// Asetetaan uudelleenohjauksen yhteydessä lisätty viesti
self::set_flash_message($content);
// Asetetaan näkymään base_path-muuttuja index.php:ssa määritellyllä BASE_PATH vakiolla
$content['base_path'] = BASE_PATH;
// Asetetaan näkymään kirjautunut käyttäjä, jos get_user_logged_in-metodi on toteutettu
if (method_exists('BaseController', 'get_user_logged_in')) {
$content['user_logged_in'] = BaseController::get_user_logged_in();
}
// Asetetaan näkymään kirjautunut admin-käyttäjä, jos get_admin_logged_in-metodi on toteutettu
if (method_exists('BaseController', 'get_admin_logged_in')) {
$content['admin_logged_in'] = BaseController::get_admin_logged_in();
}
// Tulostetaan Twig:n renderöimä näkymä
$rendered_page = $twig->render($view, $content);
echo $rendered_page;
} catch (Exception $e) {
die('Virhe näkymän näyttämisessä: ' . $e->getMessage());
}
// exit();
return $rendered_page;
}
示例3: check_user_is_manager
public static function check_user_is_manager()
{
BaseController::check_logged_in();
if (!BaseController::get_user_logged_in()->manager) {
Redirect::to(\Slim\Slim::getInstance()->urlFor('index'), array('message' => 'Sinulla ei ole oikeuksiä käyttää toimintoa!', 'error' => true));
}
}
示例4: index
public static function index()
{
self::check_logged_in();
$ryhmemos = Memo::all_groupmemos(BaseController::get_user_logged_in());
$memos = Memo::all(BaseController::get_user_logged_in());
View::make('memo/index.html', array('memos' => $memos, 'ryhmemos' => $ryhmemos));
}
示例5: save
public function save()
{
$query = DB::connection()->prepare('INSERT INTO Askare (perheenjasen_id, nimi, tarkeys, lisatty, valmis, muuta)VALUES(:perheenjasen_id, :nimi, :tarkeys, NOW(), :valmis, :muuta)RETURNING id');
$query->execute(array('perheenjasen_id' => BaseController::get_user_logged_in()->id, 'nimi' => $this->nimi, 'tarkeys' => $this->tarkeys, 'valmis' => $this->valmis, 'muuta' => $this->muuta));
$row = $query->fetch();
Kint::dump($row);
$this->id = $row['id'];
}
示例6: destroy
public static function destroy($id)
{
if (parent::is_admin() || parent::get_user_logged_in()->id == $id) {
User::destroy($id);
Redirect::to("/user", array('message' => "User was destroyed."));
} else {
Redirect::to("/", array('message' => "You are not an admin or user# " . $id));
}
}
示例7: make
public static function make($file, $content = array())
{
$twig = self::get_twig();
if (BaseController::get_flash() != null) {
$content['flash'] = BaseController::get_flash();
BaseController::set_flash(null);
}
$content['user_logged_in'] = BaseController::get_user_logged_in();
echo $twig->render($file, $content);
}
示例8: editLease
public static function editLease($id, $leaseId)
{
if (parent::logged_in_user_is_landlord_of($id)) {
$unit = RentalUnit::find($id);
$lease = Lease::find($leaseId);
$amenities = Amenity::all_and_check(Amenity::LEASE, $leaseId);
$user = parent::get_user_logged_in();
View::make('lease/lease_modify.html', array('lease' => $lease, 'unit' => $unit, 'amenities' => $amenities, 'user' => $user, 'input' => array('tenant' => $lease->tenant, 'tenant_email' => $lease->tenant_email, 'rent' => $lease->rent, 'start_date' => $lease->start_date, 'end_date' => $lease->end_date), 'edit' => true));
}
Redirect::to('/units/' . $id, array('message' => 'insufficient rights'));
}
示例9: all
public static function all()
{
$query = DB::connection()->prepare('SELECT * FROM Survey WHERE person = :person');
$user = BaseController::get_user_logged_in();
$query->execute(array('person' => $user->id));
$rows = $query->fetchAll();
$surveys = array();
foreach ($rows as $row) {
$surveys[] = new Survey(array('id' => $row['id'], 'person' => $row['person'], 'description' => $row['description'], 'min_value' => $row['min_value'], 'max_value' => $row['max_value'], 'type' => $row['type']));
}
return $surveys;
}
示例10: index
public static function index()
{
$user = BaseController::get_user_logged_in();
$services = array();
$deleted_services = null;
if ($user->manager) {
$services = Service::all();
$deleted_services = Service::all_deleted();
} else {
$services = Service::all_for_user($user->id);
}
View::make('service/index.html', array('services' => $services, 'deleted_services' => $deleted_services));
}
示例11: viewUnit
public static function viewUnit($id)
{
$unit = RentalUnit::find($id);
$amenities = Amenity::all_and_check(Amenity::RENTAL_UNIT, $id);
$landlord = User::find($unit->landlord);
$user = parent::get_user_logged_in();
$leases = Lease::find_leases_for($id);
$disabled = null;
if ($user->id != $landlord->id) {
$disabled = 'disabled';
}
View::make('rental_unit/unit.html', array('unit' => $unit, 'amenities' => $amenities, 'landlord' => $landlord, 'leases' => $leases, 'disabled' => $disabled));
}
示例12: lisaaVastaus
public static function lisaaVastaus($aiheId)
{
$lomakkeenTiedot = $_POST;
$aihe = Aihe::haeYksi($aiheId);
$viestit = $aihe->vastaukset();
$aloitus = $viestit[0];
$vastaus = new Vastaus(array('otsikko' => $aloitus->otsikko, 'teksti' => $lomakkeenTiedot['teksti'], 'laatija' => BaseController::get_user_logged_in()->id, 'aihe' => $aiheId));
$errors = $vastaus->errors();
if (count($errors) == 0) {
$vastaus->lisaa();
Redirect::to('/aihe/' . $vastaus->aihe);
} else {
View::make('uusiVastaus.html', array('aihe' => $aihe, 'teksti' => $vastaus->teksti, 'virheet' => $errors));
}
}
示例13: add
public static function add($parameters)
{
$parameters['userid'] = parent::get_user_logged_in()->id;
$parameters['username'] = parent::get_user_logged_in()->username;
$image = Image::find($parameters['image']);
$comment = new Comment($parameters);
$errors = $comment->errors();
if (count($errors) == 0) {
$comment->save();
$content['success'] = "Comment was added";
} else {
$content['errors'] = $errors;
}
return $content;
}
示例14: updatePassword
public static function updatePassword()
{
$params = $_POST;
$user = BaseController::get_user_logged_in();
if ($user == null) {
flash()->error('User was not found!');
Redirect::to('/users');
}
$user->password = $params['password'];
$errors = $user->errors();
if (count($errors) > 0) {
flash()->error(':(', 'Something was a little off...');
Redirect::to('/profile/edit', array('errors' => $errors, 'attributes' => $params));
}
$user->update();
flash(':)', 'Password updated successfully!');
Redirect::to('/');
}
示例15: lisaaAihe
public static function lisaaAihe($alueId)
{
$lomakkeenTiedot = $_POST;
$aihe = new Aihe(array('aihealue' => $alueId));
$virheetAihe = $aihe->errors();
if (count($virheetAihe) == 0) {
$aloitus = new Vastaus(array('otsikko' => $lomakkeenTiedot['otsikko'], 'teksti' => $lomakkeenTiedot['teksti'], 'laatija' => BaseController::get_user_logged_in()->id, 'aihe' => -1));
$virheetAloitus = $aloitus->errors();
if (count($virheetAloitus) == 0) {
$aihe->lisaa();
$aloitus->aihe = $aihe->id;
$aloitus->lisaa();
Redirect::to('/aihe/' . $aihe->id);
}
}
$aihealue = Aihealue::haeYksi($alueId);
View::make('uusiAihe.html', array('aihealue' => $aihealue, 'virheet' => $virheetAloitus, 'aloitus' => $aloitus));
}