예제 #1
0
파일: AdminBar.php 프로젝트: ssrsfs/blg
 public function output(Pagemill_Data $data, Pagemill_Stream $stream)
 {
     $data = $data->fork();
     $apps = array();
     foreach (Typeframe::Registry()->pages() as $page) {
         if ($page->siteid() == Typeframe::CurrentPage()->siteid()) {
             if (strpos($page->uri(), '/admin/') !== false) {
                 if ($page->allow()) {
                     $apps[] = array('title' => $page->title(), 'icon' => $page->icon(), 'uri' => $page->uri());
                 }
             }
         }
     }
     $data['applications'] = $apps;
     if (class_exists('Model_Site')) {
         $sites = new Model_Site();
         if (Typeframe::User()->get('usergroupid') != TYPEF_ADMIN_USERGROUPID) {
             $sites->innerJoin('perm', 'Model_User_Site', 'id = perm.siteid');
             $sites->where('perm.userid = ?', Typeframe::User()->get('userid'));
             $primary = new Model_User_Site();
             $primary->where('userid = ?', Typeframe::User()->get('userid'));
             $primary->where('siteid = ?', 0);
             $data['admin_primary'] = $primary->count() > 0;
         } else {
             $data['admin_primary'] = 1;
         }
         $data['sites'] = $sites;
     }
     $data->sortNodes(array('applications', 'title'));
     if (defined('TYPEF_HOST')) {
         $data['primary_host'] = TYPEF_HOST;
     }
     parent::output($data, $stream);
 }
예제 #2
0
파일: update.inc.php 프로젝트: ssrsfs/blg
<?php

$form = new Form_Handler_User(!$user->exists() || !empty($_POST['password']) ? true : false);
$form->validate();
$errors = $form->errors();
if ($errors) {
    $pm->setVariable('errors', $errors);
    $pm->setVariable('user', $form->input());
} else {
    $user->setArray($_POST, false);
    $user['password'] = $_POST['password'];
    $user->save();
    if (defined('TYPEF_HOST')) {
        $sites = Model_User_Site::ForUserId($user['userid']);
        $sites->deleteQuery();
        if (!empty($_POST['admin_siteid'])) {
            foreach ($_POST['admin_siteid'] as $siteid) {
                $site = Model_User_Site::Create();
                $site['userid'] = $user['userid'];
                $site['siteid'] = $siteid;
                $site->save();
            }
        }
    }
    Typeframe::Redirect('User saved.', Typeframe::CurrentPage()->applicationUri());
}
예제 #3
0
파일: edit.php 프로젝트: ssrsfs/blg
<?php

require_once 'common.inc.php';
$user = Model_User::Get($_REQUEST['userid']);
if (!$user->exists()) {
    Typeframe::Redirect('Invalid user specified.', Typeframe::CurrentPage()->applicationUri(), 1);
    return;
}
$pm->setVariable('user', $user);
if (class_exists('Model_User_Site')) {
    $admin_sites = new Model_User_Site();
    $admin_sites->where('userid = ?', $user['userid']);
    $admin_siteids = array();
    foreach ($admin_sites->select() as $as) {
        $admin_siteids[] = $as['siteid'];
    }
    $pm->setVariable('admin_siteids', $admin_siteids);
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    require_once 'update.inc.php';
}