本文整理汇总了PHP中hasPermissions函数的典型用法代码示例。如果您正苦于以下问题:PHP hasPermissions函数的具体用法?PHP hasPermissions怎么用?PHP hasPermissions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hasPermissions函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setAutoComplete
function setAutoComplete($block, $check = false)
{
$objResponse = new xajaxResponse();
if (!(hasPermissions('adm') && hasPermissions('mailer'))) {
return $objResponse;
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/Digest/DigestFactory.php';
if (!in_array($block, DigestFactory::$types)) {
return $objResponse;
}
$digestBlock = new $block();
$digestBlock->setCheck($check);
if (!$digestBlock->isAutoComplete()) {
return $objResponse;
}
$auto = $digestBlock->setFieldAutoComplete();
if ($auto) {
ob_start();
$digestBlock->displayBlock();
$html = ob_get_clean();
$objResponse->assign($block . $digestBlock->getNum(), 'innerHTML', $html);
$objResponse->call('setInitPosition');
$objResponse->call('initNaviButton', $block . $digestBlock->getNum());
$objResponse->call('initCheckSelect', $block . $digestBlock->getNum());
} else {
$objResponse->call('alert', 'Нет данных для автозаполнения');
return $objResponse;
}
return $objResponse;
}
示例2: savewysiwygAction
public function savewysiwygAction()
{
$db = front::og('db');
$alias = front::$_req['alias'];
// проверяем права (могут быть разные для разных страниц)
switch ($alias) {
default:
$permission = null;
}
if (!$permission || !hasPermissions($permission)) {
return;
}
$text = front::$_req['form']['n_text'];
$text = iconv('UTF-8', 'CP1251', $text);
$text = __paramValue('ckedit', $text);
$title = front::$_req['form']['title'];
$title = iconv('UTF-8', 'CP1251', $title);
$title = __paramValue('string', $title);
$save = array('title' => $title, 'n_text' => $text);
if ($alias) {
$aff = $db->update('UPDATE static_pages SET ?s WHERE (alias = ?)', $save, $alias);
if (!$aff) {
$save['alias'] = $alias;
$db->insert('static_pages', $save, false);
}
}
echo json_encode(array('success' => true, 'alias' => $alias));
}
示例3: init
/**
* Инициализация контроллера
*/
public function init($action)
{
parent::init();
$this->uid = get_uid(false);
$this->is_adm = hasPermissions('projects', $this->uid);
$this->layout = '//layouts/content-with-right-narrow-sidebar';
}
示例4: init
public function init()
{
parent::init();
stat_collector::setStamp();
// stamp
$this->uid = get_uid();
$this->is_adm = hasPermissions('tservices');
// разметка страницы с левым сайдбаром
$this->layout = '//layouts/content-with-right-sidebar';
// в сайдбаре вывести фильтр с учётом текущей категории
$this->getClips()->add('sidebar', $this->widget('TServiceFilter', array(), true));
// чтобы отрисовать фильтр и опции
# TODO добиться, чтобы $this->widget('TServiceFilter') и $this->createWidget($this,'TServiceFilter') возвращал один и тот же объект
$this->filter_widget = $this->createWidget($this, 'TServiceFilter', array());
// копия, чтобы узнать, какие опции были выбраны
$prof_id = $this->filter_widget->filter->category ? $this->filter_widget->filter->category : $this->filter_widget->filter->category_group;
//----------------------------------------------------------------------
//@todo: возможно нужно общее хранилище собираемых данных
//в течении работы скрипта с последующей передачей в GA и Adriver?
GaJsHelper::getInstance()->setTuCategories($this->filter_widget->filter->category_group, $this->filter_widget->filter->category);
adriver::getInstance()->setTuCategories($this->filter_widget->filter->category_group, $this->filter_widget->filter->category);
//----------------------------------------------------------------------
SeoTags::getInstance()->initTserviceList($prof_id, $this->filter_widget->filter->category > 0);
$this->getClips()->add('header', $this->widget('TServiceNavigation', array('category_group' => $this->filter_widget->filter->category_group, 'category' => $this->filter_widget->filter->category, 'filter_get_params' => $this->filter_widget->getUserFriendlyUrl(false)), true));
$this->getClips()->add('content_top', $this->widget('TServiceCatalogHeader', array(), true));
$this->getClips()->add('categories', $this->widget('TServiceCatalogCategories', array('category_group' => $this->filter_widget->filter->category_group, 'filter_get_params' => $this->filter_widget->getUserFriendlyUrl(false)), true));
// в футере каталога вывести список специализаций фрилансеров
$this->getClips()->add('footer', $this->widget('TServiceFreelancersCategories', array(), true));
$tserviceModel = TServiceModel::model();
$this->counter_users = $tserviceModel->countUsers();
$this->counter_tu = $tserviceModel->countTservices();
}
示例5: savewysiwygAction
function savewysiwygAction()
{
$db = front::og("db");
$alias = front::$_req["alias"];
// проверяем права (могут быть разные для разных страниц)
switch ($alias) {
default:
$permission = null;
}
if (!$permission || !hasPermissions($permission)) {
return;
}
$text = front::$_req["form"]["n_text"];
$text = iconv('UTF-8', 'CP1251', $text);
$text = __paramValue('ckedit', $text);
$title = front::$_req["form"]["title"];
$title = iconv('UTF-8', 'CP1251', $title);
$title = __paramValue('string', $title);
$save = array("title" => $title, "n_text" => $text);
if ($alias) {
$aff = $db->update("UPDATE static_pages SET ?s WHERE (alias = ?)", $save, $alias);
if (!$aff) {
$save["alias"] = $alias;
$db->insert("static_pages", $save, false);
}
}
echo json_encode(array("success" => true, "alias" => $alias));
}
示例6: init
/**
* Инициализация контроллера.
*/
public function init()
{
parent::init();
$this->is_adm = hasPermissions('tservices');
$this->is_emp = (bool) is_emp();
$this->layout = '//layouts/content-with-right-sidebar-fixed';
$this->order_model = TServiceOrderModel::model();
}
示例7: createMedium
function createMedium($url, $filename, $width, $height)
{
# Function creates a smaller version of a photo when its size is bigger than a preset size
# Excepts the following:
# (string) $url = Path to the photo-file
# (string) $filename = Name of the photo-file
# (int) $width = Width of the photo
# (int) $height = Height of the photo
# Returns the following
# (boolean) true = Success
# (boolean) false = Failure
# Set to true when creation of medium-photo failed
global $settings;
$error = false;
# Size of the medium-photo
# When changing these values,
# also change the size detection in the front-end
global $newWidth;
global $newHeight;
# Check permissions
if (hasPermissions(LYCHEE_UPLOADS_MEDIUM) === false) {
# Permissions are missing
$error = true;
echo 'Not enough persmission on the medium folder' . "\n";
}
# Is photo big enough?
# Is Imagick installed and activated?
if ($error === false && ($width > $newWidth || $height > $newHeight) && (extension_loaded('imagick') && $settings['imagick'] === '1')) {
$newUrl = LYCHEE_UPLOADS_MEDIUM . $filename;
# Read image
$medium = new Imagick();
$medium->readImage(LYCHEE . $url);
# Adjust image
$medium->scaleImage($newWidth, $newHeight, true);
# Save image
try {
$medium->writeImage($newUrl);
} catch (ImagickException $err) {
Log::notice($database, __METHOD__, __LINE__, 'Could not save medium-photo: ' . $err->getMessage());
$error = true;
echo 'Imagick Exception:' . "\n";
var_dump($e);
}
$medium->clear();
$medium->destroy();
} else {
# Photo too small or
# Imagick not installed
$error = true;
}
if ($error === true) {
return false;
}
return true;
}
示例8: MasssendingSave
function MasssendingSave($id, $txt)
{
$response = new xajaxResponse();
if (hasPermissions('masssending')) {
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/masssending.php';
masssending::UpdateText($id, $txt);
$mass = masssending::Get($id);
$response->assign('mass_txt_' . $id, 'innerHTML', reformat($mass[0]['msgtext'], 30, 0, 0, 1));
}
return $response;
}
示例9: DeletePhoto
/**
* Удаление фотографии.
*
* @param integer $id ID пользователя
*/
function DeletePhoto($id)
{
session_start();
$objResponse = new xajaxResponse();
if (hasPermissions('users')) {
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/team.php';
team::DeletePhoto($id);
$objResponse->assign('peoplephoto_' . $id, 'src', '/images/team_no_foto.gif');
$objResponse->assign('pt_photo_file', 'style.display', 'none');
}
return $objResponse;
}
示例10: AddClient
function AddClient($data)
{
$objResponse = new xajaxResponse();
require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/banners.php";
session_start();
get_uid(false);
if (!hasPermissions('banners')) {
return $objResponse;
exit;
}
if (!$_SESSION['uid']) {
return $objResponse;
exit;
}
$ban_obj = new banners();
$name = trim($data['name']);
$adr = trim($data['adr']);
$phone = trim($data['phone']);
$cont = trim($data['cont']);
$email = trim($data['email']);
$notes = trim($data['notes']);
$id = trim($data['id']);
if (!$id) {
$action = 'add';
} else {
$action = 'update';
}
if ($action == "add" && $name) {
$res = $ban_obj->AddCompany($name, $adr, $phone, $cont, $email, $notes);
if (intval($res)) {
$newid = $res;
} else {
$error = $res;
}
}
if ($action == "update" && $name && $id) {
$error = $ban_obj->EditCompany($id, $name, $adr, $phone, $cont, $email, $notes);
}
if ($newid) {
$company = $ban_obj->GetCompany($newid, $error);
}
if ($error) {
$objResponse->alert($error);
return $objResponse;
}
if (!$newid) {
$objResponse->alert('Сохранить не получилось. Может что-то не заполнили?');
return $objResponse;
}
$objResponse->call('AddClient', $company);
return $objResponse;
}
示例11: comments
/**
* Выводит дерево комментариев. Используется здесь и в xajax/contest.server.php
* @param integer $pid id проекта
* @param string $name название проекта
* @param array $comments массив с деревом комментариев (подробнее в classes/contest.php)
* @param boolean $comm_blocked автор отключил возможность оставлять комментарии?
* @param boolean $project_end проект закрыт?
* @param integer $s_level уровень вложенности комментария
* @return string HTML с кнопками управления
*/
function comments($pid, $name, &$comments, $comm_blocked, $project_end, $s_level = 0)
{
global $stop_words, $contest, $project, $session;
static $level = 0;
$level = ($s_level ? $s_level : $level) + 1;
$html = '';
$set_branch_as_read = false;
for ($i = 0, $c = count($comments); $i < $c; $i++) {
if (($comments[$i]['is_banned'] || $comments[$i]['usr_banned'] || $comments[$i]['user_blocked'] === 't') && !hasPermissions('projects') && !$contest->is_owner) {
$msg = $msg2 = 'Ответ от заблокированного пользователя';
} else {
if (!trim($comments[$i]['deleted'])) {
$sMsg = $comments[$i]['moderator_status'] === '0' ? $stop_words->replace($comments[$i]['msg']) : $comments[$i]['msg'];
$msg = reformat($sMsg, 30, 0, 0, 1);
$msg2 = reformat($comments[$i]['msg'], 30, 0, 0, 1);
} else {
$msg2 = $msg = "Комментарий удален модератором";
if (hasPermissions("comments")) {
$moderator = '';
$moderatorData = new users();
$moderatorData->GetUserByUID($comments[$i]['deluser_id']);
if ($moderatorData->login) {
$moderator = ' ' . $moderatorData->login . ' (' . $moderatorData->uname . ' ' . $moderatorData->usurname . ') ';
}
$msg2 = $msg = $msg . " {$moderator}";
}
if ($comments[$i]['deluser_id'] == $comments[$i]['user_id']) {
$msg2 = $msg = "Комментарий удален автором";
} else {
if (trim($comments[$i]['deleted_reason']) && (hasPermissions("comments") || $comments[$i]['user_id'] == get_uid(false))) {
$msg2 = $msg = $msg . "<div style='color:#ff0000'>Причина: " . $comments[$i]['deleted_reason'] . "</div>";
}
}
}
}
$a_is_banned = ($comments[$i]['is_banned'] || $comments[$i]['usr_banned']) && hasPermissions('projects');
$html .= "\n\t\t\t<li class='thread' id='thread-{$comments[$i]['id']}'" . ($level >= 9 ? " style='margin-left: 0'" : "") . ">\n\t\t\t\t<a name='c-comment-{$comments[$i]['id']}'></a>\n\t\t\t\t<div class='comment-one" . ($comments[$i]['deleted'] || $comments[$i]['hidden'] ? " comment-deleted" : "") . "' id='comment-{$comments[$i]['id']}'>\n\t\t\t\t\t<div class='contest-ea'>" . view_avatar($comments[$i]['login'], $comments[$i]['photo'], 1) . "</div>\n\t\t\t\t\t<div class='comment-body'>\n\t\t\t\t\t\t<h3 class='username'>" . $session->view_online_status($comments[$i]['login']) . "\n\t\t\t\t\t\t\t<a href='/users/{$comments[$i]['login']}' class='" . (is_emp($comments[$i]['role']) ? 'employer-name' : 'freelancer-name') . "'>{$comments[$i]['uname']} {$comments[$i]['usurname']} [{$comments[$i]['login']}]</a> " . view_mark_user($comments[$i]) . " " . ($comments[$i]['completed_cnt'] > 0 ? '<a href="/promo/bezopasnaya-sdelka/" title="Пользователь работал через Безопасную Сделку" target="_blank"><span class="b-icon b-icon__shield b-icon_top_1"></span></a>' : '') . "\n\t\t\t\t\t\t\t<span>[" . dateFormat('d.m.Y | H:i', $comments[$i]['post_date']) . "]</span>\n\t\t\t\t\t\t\t<span id='comment-modified-{$comments[$i]['id']}'>" . ($comments[$i]['modified'] ? "[изменен " . dateFormat('d.m.Y | H:i', $comments[$i]['modified']) . "]" : ' ') . "</span>\n\t\t\t\t\t\t\t" . ($a_is_banned ? "<b style=\"color:#ff0000\">Пользователь забанен</b>" : "") . "\n\t\t\t\t\t\t</h3>\n\t\t\t\t\t\t" . ($_SESSION['uid'] && $comments[$i]['is_new'] ? "<p><img src='/images/mark-new.png' width='53' height='12' alt='новое' class='mark-new' /></p>" : "") . "\n\t\t\t\t\t\t<div id='comment-change-{$comments[$i]['id']}'>\n\t\t\t\t\t\t<p id='comment-msg-{$comments[$i]['id']}' " . ($a_is_banned ? "style='color:silver'" : "") . ".>" . $msg . "</p>\n\t\t\t\t\t\t<div id='comment-msg-original-{$comments[$i]['id']}' style='display:none'>" . $msg2 . "</div>\n\t\t\t\t\t\t<script type=\"text/javascript\">\n banned.addContext( 'p{$pid}c{$comments[$i]['id']}', 3, '" . HTTP_PREFIX . "{$_SERVER['HTTP_HOST']}" . getFriendlyURL("project", $pid) . "?comm={$comments[$i]['id']}#comment-{$comments[$i]['id']}', \"" . htmlspecialchars($name) . "\" );\n </script>\n\t\t\t\t\t\t<ul class='thread-options' id='comment-options-{$comments[$i]['id']}'>\n\t\t\t\t\t\t\t" . comment_options($pid, $comments[$i], $comm_blocked, $project_end, $level, $name) . "\n\t\t\t\t\t\t</ul>\n <div id='warnreason-" . $comments[$i]['id'] . "-" . $comments[$i]['user_id'] . "' style='display:none; padding: 0 0 5px 0px;'> </div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t" . (empty($comments[$i]['comments']) ? '' : '<ul>' . comments($pid, $name, $comments[$i]['comments'], $comm_blocked, $project_end) . '</ul>') . "\n\t\t\t</li>\n\t\t";
if ($comments[$i]['is_new']) {
$set_branch_as_read = true;
}
}
if ($set_branch_as_read) {
$p = new projects();
$data = array("id" => $pid, "kind" => 7, "user_id" => $project["user_id"]);
$p->SetRead($data, get_uid(false), true);
}
--$level;
return $html;
}
示例12: SaveStatus
function SaveStatus($text, $statusType, $login = NULL)
{
session_start();
$freelancer = new freelancer();
$text = addslashes(substr(stripslashes(trim($text)), 0, 200));
close_tags($text, 's');
$freelancer->status_text = antispam(htmlspecialchars(htmlspecialchars_decode(change_q_x(trim($text), true, false), ENT_QUOTES), ENT_QUOTES));
$freelancer->status_type = intval($statusType);
if ($freelancer->statusToStr($statusType)) {
$stdStatus = "";
$objResponse = new xajaxResponse();
$uid = hasPermissions('users') && $login != $_SESSION['login'] ? $freelancer->GetUid($err, $login) : get_uid(false);
$pro = hasPermissions('users') && $login != $_SESSION['login'] ? is_pro(true, $uid) : is_pro();
$error = $freelancer->Update($uid, $res);
if (!$freelancer->status_text) {
$freelancer->status_text = $stdStatus;
}
$freelancer->status_text = stripslashes($freelancer->status_text);
switch ($freelancer->status_type) {
case 1:
$status_cls = 'b-status b-status_busy';
break;
case 2:
$status_cls = 'b-status b-status_abs';
break;
case -1:
$status_cls = 'b-status b-status_no';
break;
default:
$status_cls = 'b-status b-status_free';
}
if (!$noassign) {
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stop_words.php';
$stop_words = new stop_words(hasPermissions('users'));
$sStatusText = $pro ? $freelancer->status_text : $stop_words->replace($freelancer->status_text);
//$GLOBALS['xajax']->setCharEncoding("windows-1251");
$jsobj = json_encode(array('data' => iconv('CP1251', 'UTF8', $freelancer->status_text)));
$objResponse->assign("statusText", "innerHTML", $freelancer->status_text == $stdStatus ? "" : reformat($sStatusText, 40, 0, 1, 25));
$objResponse->assign("statusTitle", "innerHTML", $freelancer->statusToStr($statusType));
// $objResponse->assign("statusTitle", "style.display", $statusType > -1 ? '' : 'none');
$objResponse->script("statusType = {$statusType};\n\t\t\t statusTxt = document.getElementById('statusText').innerHTML;\n\t\t\t statusTxtSrc = {$jsobj};");
}
$objResponse->script("\$('bstatus').erase('class');\n \$('bstatus').addClass('{$status_cls}');");
}
return $objResponse;
}
示例13: ShowBillComms
function ShowBillComms($bill_id, $uid = 0, $mode = 1)
{
global $session;
session_start();
$objResponse = new xajaxResponse();
if ($uid && !hasPermissions('payments')) {
return $objResponse;
} elseif (!$uid) {
$uid = $_SESSION['uid'];
}
$account = new account();
if ($account->checkOperationOwner((int) $bill_id, (int) $uid)) {
$info = $account->GetHistoryInfo($bill_id, $uid, $mode);
}
if (isset($info) && $info) {
$objResponse->assign("bil" . $bill_id, "innerHTML", ($mode == 2 ? '<br/>' : '') . $info);
}
return $objResponse;
}
示例14: GetMorePrj
function GetMorePrj($uid)
{
session_start();
$objResponse = new xajaxResponse();
$html = '';
require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects_offers.php';
$prjs = projects_offers::GetFrlOffers($uid, 'marked', NULL);
$i = 0;
$uid = get_uid(FALSE);
$is_adm = hasPermissions('users');
if ($prjs) {
foreach ($prjs as $p) {
$is_link = $uid > 0 && (in_array($uid, array($p['exec_id'], $p['project_user_id'], $p['offer_user_id'])) || $is_adm);
++$i;
$html .= "<li><span class='prj_list_number'>{$i}.</span>";
if ($p['kind'] == 9) {
$html .= $is_link ? "<a href='" . getFriendlyURL('project', $p['project_id']) . "'>{$p['project_name']}</a>" : "{$p['project_name']}";
} else {
$html .= "<a href='" . getFriendlyURL('project', $p['project_id']) . "'>{$p['project_name']}</a>";
}
if ($p['position'] > 0 && $p['is_executor'] == 't') {
//$html .= " ({$p['position']}-е место)";
}
if ($p['refused'] == 't') {
$html .= "<p>Отказ: <span class='ops-minus'>" . $p['rating'] . '</span></p>';
}
if ($p['selected'] == 't') {
$html .= "<p><span>Кандидат: <span class='ops-plus'>+" . $p['rating'] . '</span></p>';
}
if ($p['is_executor'] == 't' && $p['position'] <= 0) {
$html .= "<p><span>Исполнитель: <span class='ops-plus'>+" . $p['rating'] . '</span></p>';
}
if ($p['position'] > 0) {
$html .= "<p>{$p['position']}-е место: <span class='ops-plus'>+{$p['rating']}</span></p>";
}
$html .= '</li>';
}
$objResponse->assign('prj_list', 'innerHTML', $html);
}
return $objResponse;
}
示例15: projectEditFeedback
function projectEditFeedback($feedback_id)
{
$uid = get_uid(false);
$objResponse =& new xajaxResponse();
$feedbackModel = new projects_feedback();
$data = $feedbackModel->getFeedback($feedback_id);
if (!$data) {
return $objResponse;
}
$is_adm = hasPermissions('projects');
$is_owner = $data['user_id'] == $uid;
if (!$is_owner && !$is_adm) {
return $objResponse;
}
$content = Template::render(ABS_PATH . '/projects/tpl.feedback-form.php', $data);
$ele_id = 'form_container_' . $feedback_id . '-3';
$objResponse->script("\$\$('.editFormSbr').set('html', ' ').setStyle('display', 'none');");
$objResponse->script("\$\$('.sbrmsgblock').setStyle('display', 'block');");
$objResponse->script("\$('form_container_to_{$feedback_id}-3').setStyle('display', 'none');");
$objResponse->script("\$('{$ele_id}').setStyle('display', 'block');");
$objResponse->assign($ele_id, 'innerHTML', $content);
return $objResponse;
}