本文整理汇总了PHP中Group::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::model方法的具体用法?PHP Group::model怎么用?PHP Group::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* 用户组绑定权限
*/
public function actionIndex($id)
{
$id = (int) $id;
$model = Group::model()->findByPk($id);
if ($model->access) {
foreach ($model->access as $g) {
$access[] = $g->access_id;
}
}
$cache = cache('auth_controller_file');
if (!$cache) {
$d = $this->_get_modules(\Yii::getPathOfAlias('application.modules'));
if ($d) {
Access::generate($d);
}
DirHelper::$kep_list_file = false;
cache('auth_controller_file', true);
}
$rows = DB::all('access', array('select' => "id,name,pid"));
foreach ($rows as $v) {
$out[$v['id']] = $v;
}
$rows = ArrHelper::_tree_id($rows);
if ($_POST) {
$auth = $_POST['auth'];
GroupAccess::saveAccess($id, $auth);
cache('acl', false);
flash('success', __('set access success'));
$this->redirect(url('admin/auth/index', array('id' => $id)));
}
return $this->render('index', array('rows' => $rows, 'out' => $out, 'model' => $model, 'id' => $id, 'access' => $access));
}
示例2: run
public function run()
{
$model = new UserForm();
if (($post = $this->request->getPost('UserForm', false)) !== false) {
$model->attributes = $post;
if ($model->save()) {
$this->response(200, '更新用户成功');
} else {
$this->response(500, '更新用户失败');
}
$this->app->end();
} else {
if (($id = $this->request->getQuery('id', 0)) != false) {
if (($user = User::model()->findByPk($id)) != false) {
$model->attributes = ['id' => $user->id, 'username' => $user->username, 'realname' => $user->realname, 'nickname' => $user->nickname, 'email' => $user->email, 'state' => $user->state];
$auth = $this->app->getAuthManager();
$roles = $auth->getRoleByUserId($id);
$role = [];
foreach ($roles as $item) {
$role[] = $item->getId();
}
$groups = $auth->getGroupByUserId($id);
$group = [];
foreach ($groups as $item) {
$group[] = $item->getId();
}
$this->render('edit', ['model' => $model, 'role' => $role, 'group' => $group, 'roleList' => Role::model()->findAll(), 'groupList' => Group::model()->findAll()]);
$this->app->end();
}
}
}
$this->response(404, '参数错误');
}
示例3: actionEdit
/**
* Edit a karma record
*/
public function actionEdit()
{
$_POST = Yii::app()->input->stripClean($_POST);
$id = (int) Yii::app()->request->getQuery('id');
$user = User::model()->resetScope()->findByPk($id);
$karma = Karma::model()->resetScope()->findByPk($id);
if ($karma == null) {
throw new CHttpException(404, "Karma record not found!");
}
// Build Form Definition
$definition = array();
$definition['elements'] = array();
$groupModels = Group::model()->findAll(array('order' => 'name'));
// Define Form Eleements
$definition['elements']['Karma'] = array('type' => 'form', 'title' => 'Karma', 'elements' => array('name' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 25), 'points' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 10), 'description' => array('type' => 'text', 'class' => 'form-control', 'maxlength' => 1000)));
// Get Form Definition
$definition['buttons'] = array('save' => array('type' => 'submit', 'label' => 'Save', 'class' => 'btn btn-primary'), 'delete' => array('type' => 'submit', 'label' => 'Delete', 'class' => 'btn btn-danger'));
$form = new HForm($definition);
$form['Karma']->model = $karma;
if ($form->submitted('save') && $form->validate()) {
$this->forcePostRequest();
if ($form['Karma']->model->save()) {
$this->redirect($this->createUrl('edit', array('id' => $karma->id)));
return;
}
}
if ($form->submitted('delete')) {
$this->redirect(Yii::app()->createUrl('karma/admin/delete', array('id' => $user->id)));
}
$this->render('edit', array('form' => $form));
}
示例4: actionDynamicRows
public function actionDynamicRows()
{
$selectionid = $_POST['selection'];
switch ($selectionid) {
case '1':
die;
case '2':
$selectedData = Group::model()->findAll();
$dataOptions = array('' => '--- Select Group ---');
foreach ($selectedData as $row) {
//$group = Group::model()->findByAttributes(array('name'=>$row->name));
$dataOptions[$row->id] = $row->name;
}
break;
case '3':
$selectedData = User::model()->findAll('name != :name', array(':name' => Yii::app()->user->getId()));
$dataOptions = array('' => '--- Select User ---');
foreach ($selectedData as $row) {
//$user = User::model()->findByAttributes(array('name'=>$row->name));
$dataOptions[$row->id] = $row->name;
}
break;
default:
break;
}
foreach ($dataOptions as $value => $name) {
$opt = array();
$opt['value'] = $value;
echo CHtml::tag('option', $opt, CHtml::encode($name), true);
}
die;
}
示例5: actionIndex
public function actionIndex()
{
Yii::app()->getModule('aud');
Yii::app()->getModule('group');
Yii::app()->getModule('lesson');
Yii::app()->getModule('sch');
Yii::app()->getModule('spec');
Yii::app()->getModule('teacher');
$schs = Sch::model()->findAll(array('order' => 'modified_time DESC', 'limit' => 100));
$auds = Aud::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
$specs = Spec::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
$groups = Group::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
$lessons = Lesson::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
$teachers = Teacher::model()->findAll(array('order' => 'updated_time DESC', 'limit' => 100));
$entries = $this->addEntries(array($auds, $specs, $groups, $lessons, $teachers));
foreach ($schs as $value) {
$entries[] = array('id' => $value->group_id, 'module' => strtolower(get_class($value)), 'time' => $value->modified_time . rand(100000, 999999), 'time' => $value->modified_time, 'user' => $value->modified_by, 'action' => 'update');
}
$entriesNew = array();
foreach ($entries as $value) {
$entriesNew[$value['time'] . rand(10000, 99999)] = $value;
}
krsort($entriesNew);
$this->render('index', array('entries' => $entriesNew));
}
示例6: actionDelete
/**
* Deletes a group
*
* On deletion all group members will be moved to another group.
*/
public function actionDelete()
{
Yii::import('admin.forms.*');
$id = (int) Yii::app()->request->getQuery('id');
$group = Group::model()->findByPk($id);
if ($group == null) {
throw new CHttpException(404, Yii::t('AdminModule.controllers_GroupController', 'Group not found!'));
}
// uncomment the following code to enable ajax-based validation
if (isset($_POST['ajax']) && $_POST['ajax'] === 'admin-deleteGroup-form') {
echo CActiveForm::validate($group);
Yii::app()->end();
}
$model = new AdminDeleteGroupForm();
if (isset($_POST['AdminDeleteGroupForm'])) {
$model->attributes = $_POST['AdminDeleteGroupForm'];
if ($model->validate()) {
foreach (User::model()->findAllByAttributes(array('group_id' => $group->id)) as $user) {
$user->group_id = $model->group_id;
$user->save();
}
$group->delete();
$this->redirect(Yii::app()->createUrl('//admin/group'));
}
}
$this->render('delete', array('group' => $group, 'model' => $model));
}
示例7: actionShowedit
function actionShowedit()
{
$user = Yii::app()->session['member'];
$this->data['user'] = $this->connection->createCommand("select * from xm_user where user_id = {$user['user_id']}")->queryRow();
$this->data['group'] = Group::model()->findByPk($user['group_id']);
$this->render('showedit', $this->data);
}
示例8: run
public function run()
{
$this->userinfo = User::model()->findByPk($this->userid);
if (!empty($this->isgroup)) {
$this->groupinfo = Group::model()->findByAttributes(array('group_id' => $this->isgroup));
}
$this->render('_topmenu', array('tilescount' => $this->alltiles, 'userinfo' => $this->userinfo, 'finaocount' => $this->finaocount, 'imgcount' => $this->imgcount, 'videocount' => $this->videocount, 'isshare' => $this->isshare, 'followcnt' => $this->followcnt, 'userid' => $this->userid, 'groupcnt' => $this->groupcnt, 'isgroup' => $this->isgroup, 'groupinfo' => $this->groupinfo));
}
示例9: existingGroups
public function existingGroups()
{
Yii::app()->getModule('group');
foreach (Group::model()->findAll() as $group) {
$groups[] = array($group->code, $group->year, $group->number);
}
return $groups;
}
示例10: getCurrentGroup
static function getCurrentGroup()
{
if (!isset(Yii::app()->user->group)) {
$group = Group::model()->findByPk(1);
Yii::app()->user->setState('group', $group);
}
return Yii::app()->user->group;
}
示例11: loadModel
protected function loadModel($id)
{
$model = Group::model()->findByPk($id);
if ($model === NULL) {
$this->show404();
}
return $model;
}
示例12: run
public function run()
{
$gid = $this->gid;
$group = Group::model()->loadGroup($gid);
$new_topics = $group->getGroupNewThreads();
$data = array('group' => $group, 'new_topics' => $new_topics);
$this->render('WGroupTopicSidebar', $data);
}
示例13: actionHistory
public function actionHistory($id)
{
$model = new Sch();
if (!($models = $model->schHistory($id))) {
$this->redirect('/group');
}
$this->render('history', array('models' => $models, 'group' => Group::model()->findByPk($id)));
}
示例14: run
/**
* Executes the widgets
*/
public function run()
{
$groups = Group::model()->count();
$users = User::model()->count();
$statsAvgMembers = $users / $groups;
$statsTopGroup = Group::model()->find('id = (SELECT group_id FROM user GROUP BY group_id ORDER BY count(*) DESC LIMIT 1)');
// Render widgets view
$this->render('groupStats', array('statsTotalGroups' => $groups, 'statsAvgMembers' => round($statsAvgMembers, 1), 'statsTopGroup' => $statsTopGroup, 'statsTotalUsers' => $users));
}
示例15: modifyData
public function modifyData()
{
$criteria = new CDbCriteria();
$items = Group::model()->findAll($criteria);
foreach ($items as $item) {
$groupRelation = MiniGroupRelation::getInstance()->getByGroupId($item->id);
$group = Group::model()->findByPk($item->id);
$group->parent_group_id = $groupRelation['parent_group_id'];
$group->save();
}
}