public function dashboard()
 {
     $counts = ['organizations' => Organization::count(), 'users' => User::count(), 'todos' => Todo::count(), 'mt_users' => User::has('organizations', '>', 1)->count()];
     $newestOrg = Organization::orderBy('created_at', 'desc')->first();
     $orgWithMostTodos = DB::table('organizations')->select(['organizations.name', DB::raw('count(todos.organization_id) as total')])->join('todos', 'todos.organization_id', '=', 'organizations.id')->orderBy('total', 'desc')->groupBy('todos.organization_id')->first();
     $this->view('dashboard', compact('counts', 'newestOrg', 'orgWithMostTodos'));
 }
Example #2
0
 public static function onlyHas($role)
 {
     if (User::has($role)) {
         User::$zones[] = User::getZone($role);
     } else {
         throw new Exception("Access denied!");
     }
 }
Example #3
0
 public function left_menu_item()
 {
     if (\User::has('socialc-view')) {
         echo Template::moduleView($this->module_name, 'views.scomplaint-left-menu');
     }
 }
Example #4
0
 public function left_menu_item()
 {
     if (\User::has('jobrequest-view')) {
         echo Template::moduleView($this->module_name, 'views.jobrequest-left-menu');
     }
 }
Example #5
0
 public function page_group_attachment($post)
 {
     if ($post->view_mod == $this->page_view_mod && \User::has('calendar-view')) {
         $wdata = array('post' => $post->toArray(), 'calendar_groups' => \CalendarGroup::orderBy('name', 'asc')->get(), 'selected_groups' => array());
         $selected_groups = \CalendarPostModel::where('post_id', $post->id)->get();
         foreach ($selected_groups as $item) {
             $wdata['selected_groups'][] = $item->calendar_group_id;
         }
         echo Template::moduleView($this->module_name, 'views.attachment-calendar-page', $wdata);
     }
 }
Example #6
0
                    </select>
                    <div class='c10'></div>
                    <input type='submit' value="<?php 
    echo varlang('create-3');
    ?>
" class='btn btn-success pull-right' />
                    <div class='clearfix'></div>
                </form>
            </div>
        </div>
        <?php 
}
?>
    </div><!-- /.col-lg-4 -->
    <?php 
if (isset($page) && $page && User::has("page-edit")) {
    ?>
        <div class="col-lg-8">
            <div class="box">
                <header>
                    <h5><?php 
    echo varlang('form-3');
    ?>
</h5> <a href='<?php 
    echo url('page/delete/' . $page->id);
    ?>
' onclick='return confirm("Delete this page? ");' class='label label-danger pull-right' style='line-height: 38px'><?php 
    echo varlang('delete');
    ?>
</a>
                </header>
Example #7
0
 /**
  * Push via collection
  *
  * @param $words
  */
 public function pushWords2($words)
 {
     $this->info('Done preparing. Pushing');
     //		$users = User::has('subscriptions', '>', 0)->where('device', '<>', '')->groupBy('device')->get();
     //		$devices = $users->map(function ($user) {
     //			return PushNotification::Device($user->device, ['badge', 1]);
     //		})->toArray();
     //		dd($users->map(function ($user) {
     //			if ($user->device == '4f2da0157aee52ea22718fd988df0dda80830b902c774f38f16dbf5faf2069b9')
     //				$this->comment('Found, '.$user->subscriptions->count());
     //			return $user->device;
     //		}));
     $devices = PushNotification::DeviceCollection(User::has('subscriptions', '>', 0)->where('device', '<>', '')->groupBy('device')->get()->map(function ($user) {
         $this->info($user->device);
         return PushNotification::Device($user->device, ['badge', 1]);
     })->toArray());
     PushNotification::app('IOS')->to($devices)->send("Пора знакомится с новыми словами", ["custom" => ["cdata" => $words->toArray(), "type" => 1]]);
     $this->info('Done');
 }
Example #8
0
                                <input type="checkbox"
                                    <?php 
                echo isset($file->status) && $file->status ? 'checked' : '';
                ?>
 />
                                <?php 
            }
            ?>
                        </form>
                    </td>
                    <?php 
        }
        ?>
                <td>
                    <?php 
        if (User::has('file-delete')) {
            ?>
                        <a class="btn btn-danger delete_file" data-id="<?php 
            echo $file->id;
            ?>
"
                           data-module_name="<?php 
            echo $file->module_name;
            ?>
" data-module_id="<?php 
            echo $file->module_id;
            ?>
"
                           data-update=".files-<?php 
            echo $module_name;
            ?>
Example #9
0
<form class="ajax-auto-submit" action='<?php 
echo url('page/save');
?>
' method='post'>
    <input type='hidden' name='id' value='<?php 
echo isset($page['id']) ? $page['id'] : 0;
?>
' />

    <table class="table table-bordered table-hover">
        <?php 
if (User::has('page-move')) {
    ?>
            <tr>
                <th><?php 
    echo varlang('parent-');
    ?>
</th>
                <td>
                    <select name="page[parent]" class='form-control'>
                        <option value='0'>----</option>
                        <?php 
    echo View::make('sections.page.element-tree-option', array('level' => 1, 'items' => $tree_pages, 'selected' => isset($page->parent) ? $page->parent : 0, 'exclude' => isset($page->id) ? $page->id : null));
    ?>
                    </select>
                </td>
            </tr>
        <?php 
}
?>
        <tr class="<?php 
Example #10
0
 public function left_menu_item()
 {
     if (\User::has('actelocale-view')) {
         echo Template::moduleView($this->module_name, 'views.acte-left-menu');
     }
 }
Example #11
0
 public function left_menu_item()
 {
     if (\User::has('newsletter-view')) {
         echo Template::moduleView($this->module_name, 'views.newsletter-left-menu');
     }
 }
Example #12
0
    ?>
        <tr>
            <td colspan="3">
        <center><?php 
    echo varlang('no-vars');
    ?>
</center>
    </td>
    </tr>
<?php 
}
?>
</table>

<?php 
if (User::has('var-create')) {
    ?>
    <h4><?php 
    echo varlang('create-new-var');
    ?>
</h4>

    <form method="post" action='<?php 
    echo url("var/create");
    ?>
'>
        <input type="hidden" name='parent_key' value='<?php 
    echo $var_key;
    ?>
' />
        <input type='text' name='key' value='' autocomplete="off" placeholder='<?php 
Example #13
0
        echo $nodeName;
        ?>
</a>
            </span>
            <ul>
                <?php 
        echo View::make('sections.page.block-tree', array('items' => $item['list']));
        ?>
            </ul>
        </li>
    <?php 
    } else {
        ?>
        <li>
            <?php 
        if (User::has("page-order")) {
            ?>
                <a class="label-default move-btn" href="<?php 
            echo url('page/move/' . $item->id . '/1');
            ?>
">&#65514;</a> <a class="label-default move-btn" href="<?php 
            echo url('page/move/' . $item->id . '/0');
            ?>
">&#65516;</a>
            <?php 
        }
        ?>
            <a class='<?php 
        echo isset($page->id) && $page->id == $item->id ? 'active' : '';
        ?>
' href='<?php 
Example #14
0
><?php 
        echo $role->name;
        ?>
</option>
            <?php 
    }
    ?>
        </select>

    </form>
<?php 
}
?>

<?php 
if (User::has('user-delete')) {
    ?>
    <div class="c20"></div>
    <form action="<?php 
    echo url('user/delete');
    ?>
" method="post">
        <input type="hidden" name="id" value="<?php 
    echo $user->id;
    ?>
" />

        <button type="submit" onclick="return confirm('<?php 
    echo varlang('delete-user');
    ?>
');" class="btn btn-danger pull-right"><i class="glyphicon glyphicon-remove"></i></button>
Example #15
0
 /**
  * Save page changes
  * @return type
  */
 public function postSave()
 {
     User::onlyHas("page-edit");
     $page_id = Input::get('id');
     $page = Input::get('page');
     $page_lang = Input::get('lang');
     $post = Post::find($page_id);
     if ($post && $page) {
         $post->created_at = $page['created_at'];
         $post->updated_at = date('Y-m-d G:i:s');
         if (User::has('page-move')) {
             if ($page['parent'] != $page_id) {
                 $post->parent = $page['parent'];
             }
         }
         $post->clone_id = $page['clone_id'];
         $post->redirect_to = $page['redirect_to'];
         $post->view_mod = $page['view_mod'];
         $post->general_node = isset($page['general_node']) ? 1 : 0;
         $post->is_home_page = isset($page['is_home_page']) ? 1 : 0;
         $post->have_socials = isset($page['have_socials']) ? 1 : 0;
         $post->have_comments = isset($page['have_comments']) ? 1 : 0;
         if ($post->is_home_page) {
             DB::table(Post::getTableName())->where('is_home_page', 1)->where(Post::getField('id'), '<>', $page_id)->update(array('is_home_page' => 0));
         }
         $post->save();
     }
     if ($page_lang) {
         foreach ($page_lang as $page_lang_id => $page_lang) {
             $post_lang = PostLang::find($page_lang_id);
             $post_lang->title = $page_lang['title'];
             $post_lang->text = $page_lang['text'];
             $post_lang->enabled = isset($page_lang['enabled']) && $page_lang ? 1 : 0;
             if ($page_lang['uri']) {
                 $post_lang->uri = PostLang::uniqURI($page_lang_id, $page_lang['uri']);
             } else {
                 $post_lang->uri = PostLang::uniqURI($page_lang_id, $page_lang['title']);
             }
             $post_lang->save();
         }
     }
     if ($page) {
         $properties = Input::get('properties');
         PostPropertyRel::where('post_id', $page_id)->delete();
         if (is_array($properties)) {
             foreach ($properties as $property) {
                 $prop = PostProperty::find($property);
                 if ($prop) {
                     if ($prop->is_unique) {
                         PostPropertyRel::where('post_property_id', $prop->id)->delete();
                     }
                     $newproperty = new PostPropertyRel();
                     $newproperty->post_id = $page_id;
                     $newproperty->post_property_id = $property;
                     $newproperty->save();
                 }
             }
         }
     }
     if (isset($post->clone_id) && $post->clone_id) {
         $this->clonePageLangData($post->clone_id, $post->id);
     }
     $clones = Post::where('clone_id', $post->id)->get();
     foreach ($clones as $clone) {
         $this->clonePageLangData($post->id, $clone->id);
     }
     Log::info("Edit page #{$page_id}");
     return array();
 }
 public function getUsers()
 {
     $usuarios = User::has('rol')->with('rol')->get();
     return Response::json($usuarios);
 }
Example #17
0
 public function postChangepassword()
 {
     $uid = Input::get('id');
     $uroles = User::extractRoles($uid);
     if ((User::has('user-chpwd') && !User::has('user-ptpsw', $uroles) || $uid == Auth::user()->id) == FALSE) {
         throw new Exception("Access denied;");
     }
     $password = trim(Input::get('password'));
     if ($password) {
         $user = User::find($uid);
         $user->password = Hash::make($password);
         $user->save();
     }
     Log::info('Change password #' . Input::get('id'));
     return [];
 }
Example #18
0
                            <?php 
    }
    ?>
                        </tr>
                    <?php 
}
?>
                </table>
            </td>
        </tr>

    </table>

</form>

<?php 
if (User::has('template-install')) {
    ?>
    <form action="<?php 
    echo url('template/install');
    ?>
" method="post" enctype="multipart/form-data">
        <h3><?php 
    echo varlang('upload-new-template');
    ?>
</h3>
        <label for="template_file" class="pull-left btn-success btn"><i class="glyphicon glyphicon-folder-open"></i></label>
        <input style="display: none;" type="file" id="template_file" name="template" onchange="this.form.submit()" />
    </form>
<?php 
}
Example #19
0
    ?>
                        <li class="<?php 
    echo in_array(User::getZone('feed-view'), User::$zones) ? 'active' : '';
    ?>
"><a href="<?php 
    echo url('feed');
    ?>
"><i class="fa"></i><span class="link-title">&nbsp;<?php 
    echo varlang('feeds');
    ?>
</span></a></li>
                    <?php 
}
?>
                    <?php 
if (User::has('var-edit')) {
    ?>
                        <li class="<?php 
    echo in_array(User::getZone('var-edit'), User::$zones) ? 'active' : '';
    ?>
"><a href="<?php 
    echo url('var');
    ?>
"><i class="fa"></i><span class="link-title">&nbsp;<?php 
    echo varlang('var');
    ?>
</span></a></li>
                    <?php 
}
?>
 public function testHasOneHas()
 {
     $user1 = User::create(array('name' => 'John Doe'));
     $user1->role()->create(array('title' => 'admin'));
     $user2 = User::create(array('name' => 'Jane Doe'));
     $user2->role()->create(array('title' => 'reseller'));
     User::create(array('name' => 'Mark Moe'));
     Role::create(array('title' => 'Customer'));
     $users = User::has('role')->get();
     $this->assertCount(2, $users);
     $this->assertEquals('John Doe', $users[0]->name);
     $this->assertEquals('Jane Doe', $users[1]->name);
     $users = User::has('role', '=', 0)->get();
     $this->assertCount(1, $users);
     $users = User::has('role', '!=', 0)->get();
     $this->assertCount(2, $users);
 }
Example #21
0
if (!isset($user) || $user->type !== 'SuperAdmin') {
    die('not permit');
}
switch ($target) {
    case '':
        $admins = $superadmin->listAdmin();
        break;
    case 'add':
        $msg = '';
        $ERROR_INFO = $config['error']['info'];
        $username = _post('username');
        $password = _post('password');
        if ($by_post) {
            if (empty($username)) {
                $msg = $ERROR_INFO['USERNAME_EMPTY'];
            } elseif (empty($password)) {
                $msg = $ERROR_INFO['PASSWORD_EMPTY'];
            } elseif (User::has($username)) {
                $msg = $ERROR_INFO['USER_ALREADY_EXISTS'];
            } else {
                $superadmin->createAdmin(compact('username', 'password'));
                redirect($controller);
            }
        }
        break;
    default:
        throw new Exception("unkown target: {$target}");
        break;
}
$matter = "{$view}" . ($target ? ".{$target}" : '');
$view = 'board?master';