本文整理汇总了PHP中UserMapper::isSiteAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP UserMapper::isSiteAdmin方法的具体用法?PHP UserMapper::isSiteAdmin怎么用?PHP UserMapper::isSiteAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserMapper
的用法示例。
在下文中一共展示了UserMapper::isSiteAdmin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: thisUserCanApproveEvents
/**
* Does the currently-authenticated user have rights to approve events?
*
* @return bool True if the user has rights, false otherwise
*/
public function thisUserCanApproveEvents()
{
// do we even have an authenticated user?
if (isset($this->_request->user_id)) {
$user_mapper = new UserMapper($this->_db, $this->_request);
// is user site admin?
$is_site_admin = $user_mapper->isSiteAdmin($this->_request->user_id);
if ($is_site_admin) {
return true;
}
}
return false;
}
示例2: postAction
//.........这里部分代码省略.........
} else {
// if the dates are okay, sort out timezones
$event['tz_continent'] = filter_var($request->getParameter("tz_continent"), FILTER_SANITIZE_STRING);
$event['tz_place'] = filter_var($request->getParameter("tz_place"), FILTER_SANITIZE_STRING);
try {
// make the timezone, and read in times with respect to that
$tz = new DateTimeZone($event['tz_continent'] . '/' . $event['tz_place']);
$start_date = new DateTime($request->getParameter("start_date"), $tz);
$end_date = new DateTime($request->getParameter("end_date"), $tz);
$event['start_date'] = $start_date->format('U');
$event['end_date'] = $end_date->format('U');
} catch (Exception $e) {
// the time zone isn't right
$errors[] = "The fields 'tz_continent' and 'tz_place' must be supplied and valid " . "(e.g. Europe and London)";
}
}
// optional fields - only check if we have no errors as we may need
// access to $tz.
if (!$errors) {
$href = filter_var($request->getParameter("href"), FILTER_VALIDATE_URL);
if ($href) {
$event['href'] = $href;
}
$cfp_url = filter_var($request->getParameter("cfp_url"), FILTER_VALIDATE_URL);
if ($cfp_url) {
$event['cfp_url'] = $cfp_url;
}
$cfp_start_date = strtotime($request->getParameter("cfp_start_date"));
if ($cfp_start_date) {
$cfp_start_date = new DateTime($request->getParameter("cfp_start_date"), $tz);
$event['cfp_start_date'] = $cfp_start_date->format('U');
}
$cfp_end_date = strtotime($request->getParameter("cfp_end_date"));
if ($cfp_end_date) {
$cfp_end_date = new DateTime($request->getParameter("cfp_end_date"), $tz);
$event['cfp_end_date'] = $cfp_end_date->format('U');
}
$latitude = filter_var($request->getParameter("latitude"), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
if ($latitude) {
$event['latitude'] = $latitude;
}
$longitude = filter_var($request->getParameter("longitude"), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
if ($longitude) {
$event['longitude'] = $longitude;
}
$incoming_tag_list = $request->getParameter('tags');
if (is_array($incoming_tag_list)) {
$tags = array_map(function ($tag) {
$tag = filter_var($tag, FILTER_SANITIZE_STRING);
$tag = trim($tag);
$tag = strtolower($tag);
return $tag;
}, $incoming_tag_list);
}
}
// How does it look? With no errors, we can proceed
if ($errors) {
throw new Exception(implode(". ", $errors), 400);
} else {
$user_mapper = new UserMapper($db, $request);
$event_mapper = new EventMapper($db, $request);
$event_owner = $user_mapper->getUserById($request->user_id);
$event['contact_name'] = $event_owner['users'][0]['full_name'];
// When a site admin creates an event, we want to approve it immediately
$approveEventOnCreation = $user_mapper->isSiteAdmin($request->user_id);
// Do we want to automatically approve when testing?
if (isset($this->config['features']['allow_auto_approve_events']) && $this->config['features']['allow_auto_approve_events']) {
if ($request->getParameter("auto_approve_event") == "true") {
// The test suite sends this extra field, if we got
// this far then this platform supports this
$approveEventOnCreation = true;
}
}
if ($approveEventOnCreation) {
$event_id = $event_mapper->createEvent($event, true);
// redirect to event listing
header("Location: " . $request->base . $request->path_info . '/' . $event_id, null, 201);
} else {
$event_id = $event_mapper->createEvent($event);
// set status to accepted; a pending event won't be visible
header("Location: " . $request->base . $request->path_info, null, 202);
}
// now set the current user as host and attending
$event_mapper->addUserAsHost($event_id, $request->user_id);
$event_mapper->setUserAttendance($event_id, $request->user_id);
if (isset($tags)) {
$event_mapper->setTags($event_id, $tags);
}
// Send an email if we didn't auto-approve
if (!$user_mapper->isSiteAdmin($request->user_id)) {
$event = $event_mapper->getPendingEventById($event_id, true);
$count = $event_mapper->getPendingEventsCount();
$recipients = $user_mapper->getSiteAdminEmails();
$emailService = new EventSubmissionEmailService($this->config, $recipients, $event, $count);
$emailService->sendEmail();
}
exit;
}
}
}
示例3: thisUserHasAdminOn
/**
* Does the currently-authenticated user have rights on a particular talk?
*
* @param int $talk_id The identifier for the talk to check
*
* @return bool True if the user has privileges, false otherwise
*/
public function thisUserHasAdminOn($talk_id)
{
// do we even have an authenticated user?
if (isset($this->_request->user_id)) {
$user_mapper = new UserMapper($this->_db, $this->_request);
// is user site admin?
$is_site_admin = $user_mapper->isSiteAdmin($this->_request->user_id);
if ($is_site_admin) {
return true;
}
// is user an event admin?
$sql = 'select a.uid as user_id, u.full_name' . ' from user_admin a ' . ' inner join user u on u.ID = a.uid ' . ' inner join talks t on t.event_id = rid ' . ' where rtype="event" and (rcode!="pending" OR rcode is null)' . ' AND u.ID = :user_id' . ' AND t.ID = :talk_id';
$stmt = $this->_db->prepare($sql);
$stmt->execute(array("talk_id" => $talk_id, "user_id" => $this->_request->user_id));
$results = $stmt->fetchAll();
if ($results) {
return true;
}
}
return false;
}
示例4: thisUserHasAdminOn
/**
* Does the currently-authenticated user have rights on a particular event?
*
* @param int $event_id The identifier for the event to check
* @return bool True if the user has privileges, false otherwise
*/
public function thisUserHasAdminOn($event_id)
{
// do we even have an authenticated user?
if (isset($this->_request->user_id)) {
$user_mapper = new UserMapper($this->_db, $this->_request);
// is user site admin?
$is_site_admin = $user_mapper->isSiteAdmin($this->_request->user_id);
if ($is_site_admin) {
return true;
}
// is user an event admin?
return $this->isUserAHostOn($this->_request->user_id, $event_id);
}
return false;
}
示例5: thisUserHasAdminOn
/**
* Does the currently-authenticated user have rights on a particular event?
*
* @param int $event_id The identifier for the event to check
* @return bool True if the user has privileges, false otherwise
*/
public function thisUserHasAdminOn($event_id)
{
// do we even have an authenticated user?
if (isset($this->_request->user_id)) {
$user_mapper = new UserMapper($this->_db, $this->_request);
// is user site admin?
$is_site_admin = $user_mapper->isSiteAdmin($this->_request->user_id);
if ($is_site_admin) {
return true;
}
// is user an event admin?
$sql = $this->getHostSql();
$sql .= ' AND u.ID = :user_id';
$stmt = $this->_db->prepare($sql);
$stmt->execute(array("event_id" => $event_id, "user_id" => $this->_request->user_id));
$results = $stmt->fetchAll();
if ($results) {
return true;
}
}
return false;
}