本文整理匯總了PHP中models\User::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::getInstance方法的具體用法?PHP User::getInstance怎麽用?PHP User::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::getInstance方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct()
{
parent::__construct();
$this->user_model = \models\User::getInstance();
$groups = \models\UserGroup::getInstance()->getAllGroups();
foreach ($groups as $g) {
$this->groups[$g->id] = $g;
}
}
示例2: beforeroute
public function beforeroute()
{
$this->model = \models\User::getInstance();
parent::beforeroute();
$this->fw->mset(['PARAMS.table' => 'user', 'ctrl_base' => $this->fw->get('backend_base.user'), 'core_ctrl_base' => $this->fw->get('backend_base.user_core')]);
}
示例3: getAccessibleOwners
/**
* Функция для определения списка пользователей, чьи объекты заданного типа доступны данной группе пользователей по данной операции
* @param string $object объект
* @param string $action действия
* @param array $user фссщциативный массив полей пользователя
* @return true если объеты всех пользователей, false если ничьи объекты, иначе массив идентификаторов пользователей
*/
public function getAccessibleOwners($object, $action, $user)
{
if (!in_array($action, self::$actions)) {
return false;
}
$userModel = User::getInstance();
$mapper = $this->getMapper();
$res = $mapper->find(array("group_id = ? AND object = ? AND actions LIKE ?", $user['group_id'], $object, '%' . $action . '%'));
if (!count($res)) {
return false;
}
$ids = [];
foreach ($res as $r) {
if ($r->relation == self::RELATION_NO) {
return true;
}
if ($r->relation == self::RELATION_REF) {
$ids = array_merge($ids, $userModel->getReferralsIdsForUser($user['id']));
}
if ($r->relation == self::RELATION_PARENT) {
$ids[] = $user['ref'];
}
if ($r->relation == self::RELATION_OWN) {
$ids[] = $user['id'];
}
}
if (count($ids)) {
return $ids;
}
return false;
}
示例4: getUsersByGroup
/**
* Возвращает страницу списка членов группы
*/
public function getUsersByGroup($id, $start = 0, $limit = 10)
{
$userTable = User::getInstance();
return $userTable->getGroupList($group_id, $start, $limit);
}
示例5: edit
/**
* Форма для редактировани объекта
*/
public function edit()
{
$id = $this->fw->get('PARAMS.id');
$this->node = $this->model->get($id);
if (is_null($this->node)) {
$this->fw->error(404);
} elseif (!$this->checkAccess(\models\ACL::ACTION_UPDATE, $this->node['user_id'])) {
$this->fw->error(401);
} else {
$this->fw->set('node', $this->node);
// $this->setDepend();
}
$this->setAjaxFields();
$this->setSingleRelationsSelected();
$this->setPluralRelationsSelected();
$this->fw->set('has_related_tree', $this->hasRelatedTree());
$this->fw->set('inc', 'content/edit.html');
// Список элементов контента и форму для добавления
if ($this->tableMeta->hasItems()) {
$this->fw->set('form.items_limit', $this->tableMeta->get('items_limit'));
$this->fw->set('list', $this->model->getItems($id));
if ($this->fw->get('use_app_routes')) {
$this->fw->set('create_action_url', $this->fw->alias('app_backend_content_item_create', 'table=' . $this->table . ',id=' . $this->node['id']));
$this->fw->set('upload_action_url', $this->fw->alias('app_backend_content_item_upload', 'table=' . $this->table . ',id=' . $this->node['id']));
} else {
$this->fw->set('create_action_url', $this->fw->alias('backend_content_item_create', 'table=' . $this->table . ',id=' . $this->node['id']));
$this->fw->set('upload_action_url', $this->fw->alias('backend_content_item_upload', 'table=' . $this->table . ',id=' . $this->node['id']));
}
} else {
$this->fw->set('form.items_limit', 0);
}
$this->fw->set('upload_field_action_url', $this->fw->alias('backend_content_imagefield', 'table=' . $this->table . ',id=' . $this->node['id']));
// Информация о пользователе, создавшем нод
$user = \models\User::getInstance()->get($this->node['user_id']);
$user['profile'] = \models\User::getInstance()->getProfile($this->node['user_id']);
$this->fw->set('form.user', $user);
$this->setBreadcrumbs();
}
示例6: setAuthor
private static function setAuthor($user_id)
{
$model = \models\User::getInstance();
$author = $model->getProfile($user_id);
$author['name'] = empty($author['title']) ? empty($author['af_nickname']) ? '№' . $author['id'] : $author['af_nickname'] : $author['title'];
$author['link'] = 'user/' . $user_id;
\Base::instance()->set('author', $author);
}