本文整理汇总了PHP中cmsUser::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsUser::getInstance方法的具体用法?PHP cmsUser::getInstance怎么用?PHP cmsUser::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsUser
的用法示例。
在下文中一共展示了cmsUser::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($invited_id)
{
$user = cmsUser::getInstance();
// Группы, в которые можно приглашать
$my_groups = $this->model->getInvitableGroups($user->id);
// Членства приглашаемого в группах
$his_groups = $this->model->getUserMemberships($invited_id);
// Убираем из списка группы, в которых уже состоит приглашаемый
if (is_array($my_groups) && is_array($his_groups)) {
foreach ($his_groups as $membership) {
if (isset($my_groups[$membership['group_id']])) {
unset($my_groups[$membership['group_id']]);
}
}
}
$is_submitted = $this->request->has('submit');
if ($is_submitted && $my_groups) {
$group_id = $this->request->get('group_id');
if (!isset($my_groups[$group_id])) {
cmsCore::error404();
}
if ($this->model->getInvite($group_id, $invited_id)) {
cmsUser::addSessionMessage(LANG_GROUPS_INVITE_PENDING, 'info');
$this->redirectBack();
}
return $this->sendInvite($invited_id, $group_id);
}
return cmsTemplate::getInstance()->render('invite', array('invited_id' => $invited_id, 'groups' => $my_groups));
}
示例2: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
$template = cmsTemplate::getInstance();
$entry_id = $this->request->get('id');
// Проверяем валидность
$is_valid = is_numeric($entry_id);
if (!$is_valid) {
$result = array('error' => true, 'message' => LANG_ERROR);
$template->renderJSON($result);
}
$user = cmsUser::getInstance();
$entry = $this->model->getEntry($entry_id);
$replies = $this->model->getReplies($entry_id);
if (!$replies) {
$result = array('error' => true, 'message' => LANG_ERROR);
$template->renderJSON($result);
}
$permissions = array('add' => $user->is_logged, 'delete' => $user->is_admin || $user->id == $entry['profile_id']);
$html = $template->renderInternal($this, 'entry', array('entries' => $replies, 'user' => $user, 'permissions' => $permissions));
// Формируем и возвращаем результат
$result = array('error' => false, 'html' => $html);
$template->renderJSON($result);
}
示例3: getWidget
public function getWidget($title, $target, $permissions = array())
{
$user = cmsUser::getInstance();
extract($target);
$page = $this->request->get('page', 1);
$show_id = $this->request->get('wid');
$go_reply = $this->request->get('reply', 0);
$show_reply_id = 0;
if ($show_id) {
$entry = $this->model->getEntry($show_id);
if ($entry) {
if ($entry['parent_id'] > 0) {
$show_id = $entry['parent_id'];
$show_reply_id = $entry['id'];
}
$page = $this->model->getEntryPageNumber($show_id, $target, self::$perpage);
}
}
$total = $this->model->getEntriesCount($profile_type, $profile_id);
$entries = $this->model->getEntries($profile_type, $profile_id, $page);
$entries = cmsEventsManager::hook('wall_before_list', $entries);
$csrf_token_seed = implode('/', array($profile_type, $profile_id));
$template = cmsTemplate::getInstance();
return $template->renderInternal($this, 'list', array('title' => $title, 'user' => $user, 'controller' => $controller, 'profile_type' => $profile_type, 'profile_id' => $profile_id, 'user' => $user, 'entries' => $entries, 'permissions' => $permissions, 'page' => $page, 'perpage' => wall::$perpage, 'total' => $total, 'max_entries' => $show_id ? 0 : 5, 'csrf_token_seed' => $csrf_token_seed, 'show_id' => $show_id, 'show_reply_id' => $show_reply_id, 'go_reply' => $go_reply));
}
示例4: parseHide
private function parseHide($text, $hidden = false)
{
$inUser = cmsUser::getInstance();
global $_LANG;
$pattern = '/\\[hide(?:=?)([0-9]*)\\](.*?)\\[\\/hide\\]/sui';
preg_match($pattern, $text, $matches);
if (!$matches) {
return $text;
}
if ($hidden) {
$replacement = '<noindex>' . $_LANG['P_HIDE_TEXT_MOD'] . '</noindex>';
} else {
if (!$inUser->id) {
$replacement = '<noindex><div class="bb_tag_hide">' . $_LANG['P_HIDE_TEXT'] . '</div></noindex>';
} else {
if (!$matches[1]) {
$replacement = '<div class="bb_tag_hide">${2}</div>';
} elseif ($inUser->rating > $matches[1] || $inUser->is_admin) {
$replacement = '<div class="bb_tag_hide">${2}</div>';
} else {
$replacement = '<div class="bb_tag_hide">' . sprintf($_LANG['P_HIDE_TEXT_RATING'], cmsCore::spellCount($matches[1], $_LANG['P_ITEM1'], $_LANG['P_ITEM2'], $_LANG['P_ITEM10'])) . '</div>';
}
}
}
return preg_replace($pattern, $replacement, $text);
}
示例5: sendInvites
private function sendInvites($profile, $emails_list)
{
$user = cmsUser::getInstance();
$results = array('success' => array(), 'failed' => array());
$emails = string_explode_list($emails_list);
$auth_controller = cmsCore::getController('auth');
$auth_model = cmsCore::getModel('auth');
$messenger = cmsCore::getController('messages');
foreach ($emails as $email) {
if ($this->validate_email($email) !== true) {
$results['failed'][$email] = ERR_VALIDATE_EMAIL;
continue;
}
if ($this->model->getUserByEmail($email)) {
$results['failed'][$email] = LANG_REG_EMAIL_EXISTS;
continue;
}
if (!$auth_controller->isEmailAllowed($email)) {
$results['failed'][$email] = LANG_AUTH_RESTRICTED_EMAILS;
continue;
}
$invite = $auth_model->getNextInvite($user->id);
$to = array('email' => $email, 'name' => $email);
$letter = array('name' => 'users_invite');
$messenger->sendEmail($to, $letter, array('nickname' => $user->nickname, 'code' => $invite['code'], 'page_url' => href_to_abs('auth', 'register') . "?inv={$invite['code']}"));
$results['success'][$email] = true;
$auth_model->markInviteSended($invite['id'], $user->id, $email);
if (sizeof($results['success']) + sizeof($results['failed']) >= $profile['invites_count']) {
break;
}
}
return $results;
}
示例6: run
public function run()
{
$user = cmsUser::getInstance();
$id = $this->request->get('id', 0);
if (!$id) {
cmsCore::error404();
}
$folder = $this->model->getContentFolder($id);
if (!$folder) {
cmsCore::error404();
}
if ($folder['user_id'] != $user->id && !$user->is_admin) {
cmsCore::error404();
}
$ctype = $this->model->getContentType($folder['ctype_id']);
$form = $this->getForm('folder');
// Форма отправлена?
$is_submitted = $this->request->has('submit');
if ($is_submitted) {
// Парсим форму и получаем поля записи
$updated_folder = $form->parse($this->request, $is_submitted);
// Проверям правильность заполнения
$errors = $form->validate($this, $updated_folder);
if (!$errors) {
// Обновляем папку и редиректим на ее просмотр
$this->model->updateContentFolder($id, $updated_folder);
$this->redirect(href_to('users', $folder['user_id'], array('content', $ctype['name'], $folder['id'])));
}
if ($errors) {
cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error');
}
}
return cmsTemplate::getInstance()->render('folder_form', array('ctype' => $ctype, 'folder' => $folder, 'form' => $form, 'errors' => isset($errors) ? $errors : false));
}
示例7: mod_calendar_eventview
function mod_calendar_eventview($module_id)
{
$inCore = cmsCore::getInstance();
$inUser = cmsUser::getInstance();
$DB = cmsDatabase::getInstance();
$cfg = $inCore->loadComponentConfig('calendar');
if ($inUser->id != 0 and $cfg['calendar_module'] == "user") {
//Запрос к БД
$sql = "\r\n\tSELECT cms_events.* ,\r\n\tcms_events_category.tx,\r\n\tcms_events_category.bg\r\n\tFROM cms_events \r\n\tLEFT JOIN cms_events_signup ON cms_events.id=cms_events_signup.event_id \r\n\tLEFT JOIN cms_events_category ON cms_events.category_id = cms_events_category.id\r\n\tWHERE \r\n\tcms_events.start_time > " . time() . " AND \r\n\tcms_events.author_id = " . $inUser->id . " OR \r\n\tcms_events_signup.user_id = " . $inUser->id . " AND \r\n\tcms_events.author_id <> " . $inUser->id . " AND \r\n\tcms_events.start_time > " . time() . " \r\n\tGROUP BY cms_events.id ORDER BY cms_events.start_time ASC LIMIT " . $cfg['calendar_module_count'];
} else {
$sql = "SELECT cms_events.*,\r\n\t cms_events_category.tx,\r\n\t cms_events_category.bg\r\n\t FROM cms_events\r\n\t LEFT JOIN cms_events_category ON cms_events.category_id = cms_events_category.id\t \r\n\t WHERE cms_events.`type` = 'public' \r\n\t AND cms_events.start_time > " . time() . " \r\n\t ORDER BY cms_events.start_time ASC LIMIT " . $cfg['calendar_module_count'];
}
$result = $DB->query($sql);
if ($DB->error()) {
return false;
}
$events = array();
while ($event = $DB->fetch_assoc($result)) {
if ($event['author_id'] == $inUser->id) {
$event['time'] == "";
}
if ($event['category_id'] == 0) {
$event['bg'] = '#C3BCB9';
$event['tx'] = '#000000';
}
$events[] = $event;
}
$smarty = $inCore->initSmarty('modules', 'mod_calendar_eventview.tpl');
$smarty->assign('events', $events);
$smarty->display('mod_calendar_eventview.tpl');
return true;
}
示例8: run
public function run()
{
$user = cmsUser::getInstance();
$is_allowed = $user->isInGroups($this->options['groups_allowed']);
$contacts = $this->model->getContacts($user->id);
cmsTemplate::getInstance()->render('index', array('user' => $user, 'is_allowed' => $is_allowed, 'contacts' => $contacts));
}
示例9: execute
public function execute($event, $user)
{
parent::execute();
$inCore = cmsCore::getInstance();
$inUser = cmsUser::getInstance();
$inCore->loadModel('usermaps');
$model = new cms_model_usermaps();
$catalogs = array();
$user_id = $user['id'];
$limit = $this->config['Количество объектов'];
$steep = $this->config['Квадрат поиска в метрах'];
$have_point = $model->getUserPlace($user_id);
if ($have_point) {
$points = $model->getArround($have_point['id']);
}
ob_start();
if ($have_point and $inUser->id == $user_id) {
$smarty = $this->inCore->initSmarty('plugins', 'p_places_sosedi.tpl');
$smarty->assign('total', count($points));
$smarty->assign('points', $points);
$smarty->display('p_places_sosedi.tpl');
}
$html = ob_get_clean();
return $html;
}
示例10: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
if (!cmsUser::isAllowed('comments', 'delete')) {
cmsCore::error404();
}
$comment = $this->model->getComment((int) $this->request->get('id'));
// Проверяем
if (!$comment) {
cmsTemplate::getInstance()->renderJSON($result = array('error' => true, 'message' => LANG_ERROR));
}
$user = cmsUser::getInstance();
if (!cmsUser::isAllowed('comments', 'delete', 'all') && !cmsUser::isAllowed('comments', 'delete', 'full_delete')) {
if (cmsUser::isAllowed('comments', 'delete', 'own') && $comment['user']['id'] != $user->id) {
cmsTemplate::getInstance()->renderJSON(array('error' => true, 'message' => LANG_ERROR));
}
}
// проверяем, есть ли дети комментария
$is_comment_child = $this->model->getItemByField('comments', 'parent_id', $comment['id']);
$this->model->deleteComment($comment['id'], !$is_comment_child && cmsUser::isAllowed('comments', 'delete', 'full_delete', true));
if (cmsUser::isAllowed('comments', 'delete', 'full_delete')) {
cmsEventsManager::hook('comments_after_delete', $comment['id']);
} else {
cmsEventsManager::hook('comments_after_hide', $comment['id']);
}
cmsTemplate::getInstance()->renderJSON(array('error' => false, 'message' => LANG_COMMENT_DELETED));
}
示例11: mod_menu
function mod_menu($mod, $cfg)
{
$inCore = cmsCore::getInstance();
$inUser = cmsUser::getInstance();
$menuid = $inCore->menuId();
$full_menu = $inCore->getMenuStruct();
$current_uri = '/' . $inCore->getUri();
if (!isset($cfg['menu'])) {
$menu = 'mainmenu';
} else {
$menu = $cfg['menu'];
}
if (!isset($cfg['show_home'])) {
$cfg['show_home'] = 1;
}
if (!isset($cfg['is_sub_menu'])) {
$cfg['is_sub_menu'] = 0;
}
// текущий пункт меню
$currentmenu = isset($full_menu[$menuid]) ? $full_menu[$menuid] : array();
// результирующий массив меню
$items = array();
// id корня меню если обычный вывод меню, $menuid если режим подменю
if ($cfg['is_sub_menu']) {
// в подменю не должно быть ссылки на главную
$cfg['show_home'] = 0;
// на главной или нет активного пункта меню
if ($menuid == 1 || !$currentmenu) {
return false;
}
foreach ($full_menu as $item) {
if ($item['NSLeft'] > $currentmenu['NSLeft'] && $item['NSRight'] < $currentmenu['NSRight'] && in_array($menu, $item['menu']) && ($item['is_lax'] || cmsCore::checkContentAccess($item['access_list'], false)) && $item['published']) {
$item['link'] = cmsUser::stringReplaceUserProperties($item['link']);
$item['title'] = cmsUser::stringReplaceUserProperties($item['title'], true);
$items[] = $item;
// массивы для сортировки
$nsl[] = $item['NSLeft'];
$ord[] = $item['ordering'];
}
}
} else {
foreach ($full_menu as $item) {
if (in_array($menu, $item['menu']) && ($item['is_lax'] || cmsCore::checkContentAccess($item['access_list'], false)) && $item['published']) {
$item['link'] = cmsUser::stringReplaceUserProperties($item['link']);
$item['title'] = cmsUser::stringReplaceUserProperties($item['title'], true);
$items[] = $item;
// массивы для сортировки
$nsl[] = $item['NSLeft'];
$ord[] = $item['ordering'];
}
}
}
if (!$items) {
return false;
}
// сортируем массив
array_multisort($nsl, SORT_ASC, $ord, SORT_ASC, $items);
cmsPage::initTemplate('modules', $cfg['tpl'])->assign('menuid', $menuid)->assign('currentmenu', $currentmenu)->assign('current_uri', $current_uri)->assign('menu', $menu)->assign('items', $items)->assign('last_level', 0)->assign('user_id', $inUser->id)->assign('is_admin', $inUser->is_admin)->assign('cfg', $cfg)->display($cfg['tpl']);
return true;
}
示例12: run
public function run($profile, $tab_name)
{
$user = cmsUser::getInstance();
// Доступность профиля для данного пользователя
if (!$user->isPrivacyAllowed($profile, 'users_profile_view')) {
cmsCore::error404();
}
$arguments = func_get_args();
$tabs_menu = $this->getProfileMenu($profile);
if (!isset($this->tabs[$tab_name]) || !$this->tabs[$tab_name]) {
cmsCore::error404();
}
$tab = $this->tabs[$tab_name];
if (!isset($this->tabs_controllers[$tab['controller']])) {
cmsCore::error404();
}
$controller = $this->tabs_controllers[$tab['controller']];
unset($this->tabs);
unset($this->tabs_controllers);
$html = $controller->runHook('user_tab_show', $arguments);
if (!$html) {
cmsCore::error404();
}
cmsTemplate::getInstance()->render('profile_tab', array('tabs' => $tabs_menu, 'profile' => $profile, 'user' => $user, 'html' => $html));
}
示例13: photomap
public function photomap($photo)
{
$inCore = cmsCore::getInstance();
$inUser = cmsUser::getInstance();
$type = "photo";
if ($photo['user_id'] == $inUser->id) {
$is_author = TRUE;
}
$sql = mysql_query("SELECT * FROM cms_places_events WHERE `object_id` = '" . $photo['id'] . "' AND `object_type` = '{$type}'");
$cfg = $inCore->loadComponentConfig('usermaps');
ob_start();
if (mysql_num_rows($sql) == 1 or $is_author) {
$point = mysql_fetch_assoc($sql);
if ($point['x'] == "" or $point['y'] == "") {
$center = $cfg['maps_center'];
$have_point = FALSE;
} else {
$center = '"' . $point['x'] . '","' . $point['y'] . '"';
$have_point = TRUE;
}
$smarty = $this->inCore->initSmarty('plugins', 'p_places_imagesonmap.tpl');
$smarty->assign('is_author', $is_author);
$smarty->assign('photo_id', $photo['id']);
$smarty->assign('photo_type', $type);
$smarty->assign('center', $center);
$smarty->assign('cfg', $cfg);
$smarty->assign('have_point', $have_point);
$smarty->display('p_places_imagesonmap.tpl');
}
$html = ob_get_clean();
return $html;
}
示例14: run
public function run($group)
{
$user = cmsUser::getInstance();
if (!cmsUser::isAllowed('groups', 'delete')) {
cmsCore::error404();
}
if (!cmsUser::isAllowed('groups', 'delete', 'all') && $group['owner_id'] != $user->id) {
cmsCore::error404();
}
if ($this->request->has('submit')) {
// подтвержение получено
$csrf_token = $this->request->get('csrf_token');
$is_delete_content = $this->request->get('is_delete_content', false);
if (!cmsForm::validateCSRFToken($csrf_token)) {
cmsCore::error404();
}
$this->model->removeContentFromGroup($group['id'], $is_delete_content);
$this->model->deleteGroup($group['id']);
cmsUser::addSessionMessage(sprintf(LANG_GROUPS_DELETED, $group['title']));
$this->redirectToAction('');
} else {
// спрашиваем подтверждение
return cmsTemplate::getInstance()->render('group_delete', array('user' => $user, 'group' => $group));
}
}
示例15: run
public function run()
{
if (!$this->request->isAjax()) {
cmsCore::error404();
}
if (!cmsUser::isAllowed('comments', 'edit')) {
cmsCore::error404();
}
$comment_id = $this->request->get('id');
// Проверяем валидность
$is_valid = is_numeric($comment_id);
if (!$is_valid) {
$result = array('error' => true, 'message' => LANG_ERROR);
cmsTemplate::getInstance()->renderJSON($result);
}
$user = cmsUser::getInstance();
$comment = $this->model->getComment($comment_id);
if (!cmsUser::isAllowed('comments', 'edit', 'all')) {
if (cmsUser::isAllowed('comments', 'edit', 'own') && $comment['user']['id'] != $user->id) {
$result = array('error' => true, 'message' => LANG_ERROR);
cmsTemplate::getInstance()->renderJSON($result);
}
}
// Формируем и возвращаем результат
$result = array('error' => $comment ? false : true, 'id' => $comment_id, 'html' => $comment ? string_strip_br($comment['content']) : false);
cmsTemplate::getInstance()->renderJSON($result);
}