本文整理汇总了PHP中JEVHelper::getAuthorisedUser方法的典型用法代码示例。如果您正苦于以下问题:PHP JEVHelper::getAuthorisedUser方法的具体用法?PHP JEVHelper::getAuthorisedUser怎么用?PHP JEVHelper::getAuthorisedUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JEVHelper
的用法示例。
在下文中一共展示了JEVHelper::getAuthorisedUser方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save($array, &$queryModel, $rrule, $dryrun = false)
{
$cfg =& JEVConfig::getInstance();
$db =& JFactory::getDBO();
$user = JFactory::getUser();
// Allow plugins to check data validity
$dispatcher =& JDispatcher::getInstance();
JPluginHelper::importPlugin("jevents");
$res = $dispatcher->trigger('onBeforeSaveEvent', array(&$array, &$rrule, $dryrun));
// TODO do error and hack checks here
$ev_id = intval(JArrayHelper::getValue($array, "evid", 0));
$newevent = $ev_id == 0;
$data = array();
// TODO add UID to edit form
$data["UID"] = JArrayHelper::getValue($array, "uid", md5(uniqid(rand(), true)));
$data["X-EXTRAINFO"] = JArrayHelper::getValue($array, "extra_info", "");
$data["LOCATION"] = JArrayHelper::getValue($array, "location", "");
$data["allDayEvent"] = JArrayHelper::getValue($array, "allDayEvent", "off");
$data["CONTACT"] = JArrayHelper::getValue($array, "contact_info", "");
$data["DESCRIPTION"] = JArrayHelper::getValue($array, "jevcontent", "");
$data["publish_down"] = JArrayHelper::getValue($array, "publish_down", "2006-12-12");
$data["publish_up"] = JArrayHelper::getValue($array, "publish_up", "2006-12-12");
$data["SUMMARY"] = JArrayHelper::getValue($array, "title", "");
$data["URL"] = JArrayHelper::getValue($array, "url", "");
// If user is jevents can deleteall or has backend access then allow them to specify the creator
$jevuser = JEVHelper::getAuthorisedUser();
$creatorid = JRequest::getInt("jev_creatorid", 0);
if ($creatorid > 0) {
if (JVersion::isCompatible("1.6.0")) {
//$access = JAccess::check($user->id, "core.deleteall","com_jevents");
$access = $user->authorise('core.admin', 'com_jevents');
} else {
// Get an ACL object
$acl =& JFactory::getACL();
$grp = $acl->getAroGroup($user->get('id'));
$access = $acl->is_group_child_of($grp->name, 'Public Backend');
}
if ($jevuser && $jevuser->candeleteall || $access) {
$data["X-CREATEDBY"] = $creatorid;
}
}
$ics_id = JArrayHelper::getValue($array, "ics_id", 0);
if ($data["allDayEvent"] == "on") {
$start_time = "00:00";
} else {
$start_time = JArrayHelper::getValue($array, "start_time", "08:00");
}
$publishstart = $data["publish_up"] . ' ' . $start_time . ':00';
$data["DTSTART"] = JevDate::strtotime($publishstart);
if ($data["allDayEvent"] == "on") {
$end_time = "00:00";
} else {
$end_time = JArrayHelper::getValue($array, "end_time", "15:00");
}
$publishend = $data["publish_down"] . ' ' . $end_time . ':00';
if (isset($array["noendtime"]) && $array["noendtime"]) {
$publishend = $data["publish_down"] . ' 23:59:59';
}
$data["DTEND"] = JevDate::strtotime($publishend);
// iCal for whole day uses 00:00:00 on the next day JEvents uses 23:59:59 on the same day
list($h, $m, $s) = explode(":", $end_time . ':00');
if ($h + $m + $s == 0 && $data["allDayEvent"] == "on" && $data["DTEND"] > $data["DTSTART"]) {
//if (($h+$m+$s)==0 && $data["allDayEvent"]=="on" && $data["DTEND"]>=$data["DTSTART"]) {
//$publishend = JevDate::strftime('%Y-%m-%d 23:59:59',($data["DTEND"]-86400));
$publishend = JevDate::strftime('%Y-%m-%d 23:59:59', $data["DTEND"]);
$data["DTEND"] = JevDate::strtotime($publishend);
}
$data["RRULE"] = $rrule;
$data["MULTIDAY"] = JArrayHelper::getValue($array, "multiday", "1");
$data["NOENDTIME"] = JArrayHelper::getValue($array, "noendtime", "0");
$data["X-COLOR"] = JArrayHelper::getValue($array, "color", "");
$data["LOCKEVENT"] = JArrayHelper::getValue($array, "lockevent", "0");
// Add any custom fields into $data array
foreach ($array as $key => $value) {
if (strpos($key, "custom_") === 0) {
$data[$key] = $value;
}
}
$vevent = iCalEvent::iCalEventFromData($data);
$vevent->catid = JArrayHelper::getValue($array, "catid", 0);
if (is_array($vevent->catid)) {
JArrayHelper::toInteger($vevent->catid);
}
// if catid is empty then use the catid of the ical calendar
if (is_string($vevent->catid) && $vevent->catid <= 0 || is_array($vevent->catid) && count($vevent->catid) == 0) {
$query = "SELECT catid FROM #__jevents_icsfile WHERE ics_id={$ics_id}";
$db->setQuery($query);
$vevent->catid = $db->loadResult();
}
$vevent->access = intval(JArrayHelper::getValue($array, "access", 0));
if (!JVersion::isCompatible("1.6.0")) {
$vevent->access = $vevent->access > $user->aid ? $user->aid : $vevent->access;
}
$vevent->state = intval(JArrayHelper::getValue($array, "state", 0));
// Shouldn't really do this like this
$vevent->_detail->priority = intval(JArrayHelper::getValue($array, "priority", 0));
// FRONT END AUTO PUBLISHING CODE
$frontendPublish = JEVHelper::isEventPublisher();
if (!$frontendPublish) {
$frontendPublish = JEVHelper::canPublishOwnEvents($ev_id);
//.........这里部分代码省略.........
示例2: canUserEdit
function canUserEdit()
{
$is_event_creator = JEVHelper::isEventCreator();
$user = JFactory::getUser();
// are we authorised to do anything with this category or calendar
$jevuser = JEVHelper::getAuthorisedUser();
if ($this->_icsid > 0 && $jevuser && $jevuser->calendars != "" && $jevuser->calendars != "all") {
$allowedcals = explode("|", $jevuser->calendars);
if (!in_array($this->_icsid, $allowedcals)) {
return false;
}
}
if ($this->_catid > 0 && $jevuser && $jevuser->categories != "" && $jevuser->categories != "all") {
$allowedcats = explode("|", $jevuser->categories);
if (!in_array($this->_catid, $allowedcats)) {
return false;
}
}
// if can create events and this was created by this user then can edit (not valid for anon users)
if ($is_event_creator && $this->isEditable() && $this->created_by() == $user->id && $user->id > 0) {
return true;
}
// if "event publisher" or "event editor" can always edit event
if (JEVHelper::canEditEvent($this)) {
return true;
}
if (JEVHelper::canPublishEvent($this)) {
return true;
}
return false;
}
示例3: setCreatorLookup
protected function setCreatorLookup()
{
// If user is jevents can deleteall or has backend access then allow them to specify the creator
$jevuser = JEVHelper::getAuthorisedUser();
$user = JFactory::getUser();
if (JVersion::isCompatible("1.6.0")) {
//$access = JAccess::check($user->id, "core.deleteall", "com_jevents");
$access = $user->authorise('core.admin', 'com_jevents');
} else {
// Get an ACL object
$acl =& JFactory::getACL();
$grp = $acl->getAroGroup($user->get('id'));
// if no valid group (e.g. anon user) then skip this.
if (!$grp) {
return;
}
$access = $acl->is_group_child_of($grp->name, 'Public Backend');
}
$db = JFactory::getDBO();
if ($jevuser && $jevuser->candeleteall || $access) {
if (JVersion::isCompatible("1.6.0")) {
$params =& JComponentHelper::getParams(JEV_COM_COMPONENT);
$authorisedonly = $params->get("authorisedonly", 0);
// if authorised only then load from database
if ($authorisedonly) {
$sql = "SELECT tl.*, ju.* FROM #__jev_users AS tl ";
$sql .= " LEFT JOIN #__users as ju ON tl.user_id=ju.id ";
$sql .= " WHERE tl.cancreate=1";
$sql .= " ORDER BY ju.name ASC";
$db->setQuery($sql);
$users = $db->loadObjectList();
} else {
$rules = JAccess::getAssetRules("com_jevents", true);
$creatorgroups = $rules->getData();
// need to merge the arrays because of stupid way Joomla checks super user permissions
//$creatorgroups = array_merge($creatorgroups["core.admin"]->getData(), $creatorgroups["core.create"]->getData());
// use union orf arrays sincee getData no longer has string keys in the resultant array
//$creatorgroups = $creatorgroups["core.admin"]->getData()+ $creatorgroups["core.create"]->getData();
// use union orf arrays sincee getData no longer has string keys in the resultant array
$creatorgroupsdata = $creatorgroups["core.admin"]->getData();
// take the higher permission setting
foreach ($creatorgroups["core.create"]->getData() as $creatorgroup => $permission) {
if ($permission) {
$creatorgroupsdata[$creatorgroup] = $permission;
}
}
$users = array(0);
foreach ($creatorgroupsdata as $creatorgroup => $permission) {
if ($permission == 1) {
$users = array_merge(JAccess::getUsersByGroup($creatorgroup, true), $users);
}
}
$sql = "SELECT * FROM #__users where id IN (" . implode(",", array_values($users)) . ") ORDER BY name asc";
$db->setQuery($sql);
$users = $db->loadObjectList();
}
} else {
$db = JFactory::getDBO();
$params =& JComponentHelper::getParams(JEV_COM_COMPONENT);
$authorisedonly = $params->get("authorisedonly", 0);
// if authorised only then load from database
if ($authorisedonly) {
$sql = "SELECT tl.*, ju.* FROM #__jev_users AS tl ";
$sql .= " LEFT JOIN #__users as ju ON tl.user_id=ju.id ";
$sql .= " WHERE tl.cancreate=1";
$sql .= " ORDER BY ju.name ASC";
$db->setQuery($sql);
$users = $db->loadObjectList();
} else {
$params =& JComponentHelper::getParams(JEV_COM_COMPONENT);
$minaccess = $params->getValue("jevcreator_level", 19);
$sql = "SELECT * FROM #__users where gid>=" . $minaccess;
$sql .= " ORDER BY name ASC";
$db->setQuery($sql);
$users = $db->loadObjectList();
}
}
$userOptions[] = JHTML::_('select.option', '-1', JText::_('SELECT_USER'));
foreach ($users as $user) {
$userOptions[] = JHTML::_('select.option', $user->id, $user->name . " ( " . $user->username . " )");
}
$creator = $this->row->created_by() > 0 ? $this->row->created_by() : (isset($jevuser) ? $jevuser->user_id : 0);
$userlist = JHTML::_('select.genericlist', $userOptions, 'jev_creatorid', 'class="inputbox" size="1" ', 'value', 'text', $creator);
$this->assignRef("users", $userlist);
}
}
示例4: csvimport
function csvimport()
{
if (!JFactory::getApplication()->isAdmin()) {
JError::raiseError(403, JText::_('ALERTNOTAUTH'));
}
// get the view
$this->view =& $this->getView("icalevent", "html");
// get all the raw native calendars
$nativeCals = $this->dataModel->queryModel->getNativeIcalendars();
// Strip this list down based on user permissions
$jevuser =& JEVHelper::getAuthorisedUser();
if ($jevuser && $jevuser->calendars != "" && $jevuser->calendars != "all") {
$cals = array_keys($nativeCals);
$allowedcals = explode("|", $jevuser->calendars);
foreach ($cals as $calid) {
if (!in_array($calid, $allowedcals)) {
unset($nativeCals[$calid]);
}
}
}
// only offer a choice of native calendars if it exists!
if (count($nativeCals) > 0) {
$icalList = array();
$icalList[] = JHTML::_('select.option', '0', JText::_('JEV_EVENT_CHOOSE_ICAL'), 'ics_id', 'label');
$icalList = array_merge($icalList, $nativeCals);
$callist = JHTML::_('select.genericlist', $icalList, 'ics_id', " onchange='preselectCategory(this);'", 'ics_id', 'label', 0);
$this->view->assign('callist', $callist);
} else {
JError::raiseWarning(870, JText::_('INVALID_CALENDAR_STRUCTURE'));
}
// Set the layout
$this->view->setLayout('csvimport');
$this->view->display();
}
示例5: buildCategorySelect
/**
* Build HTML selection list of categories
*
* @param int $catid Selected catid
* @param string $args Additional HTML attributes for the <select> tag
* @param string $catidList Restriction list of categories
* @param boolean $with_unpublished Set true to build list with unpublished categories
* @param boolean $require_sel First entry: true = Choose one category, false = All categories
* @param int $catidtop Top level category ancestor
*/
public static function buildCategorySelect($catid, $args, $catidList = null, $with_unpublished = false, $require_sel = false, $catidtop = 0, $fieldname = "catid", $sectionname = JEV_COM_COMPONENT, $excludeid = false, $order = "ordering", $eventediting = false)
{
// need to declare this because of bug in Joomla JHtml::_('select.options', on content pages - it loade the WRONG CLASS!
include_once JPATH_SITE . "/libraries/cms/html/category.php";
ob_start();
$t_first_entry = $require_sel ? JText::_('JEV_EVENT_CHOOSE_CATEG') : JText::_('JEV_EVENT_ALLCAT');
$options = JHtml::_('category.options', $sectionname);
/* hide second level categories
for ($i=0;$i<count($options);$i++){
if (strpos($options[$i]->text,"-")!==false){
unset($options[$i]);
}
}
$options = array_values($options);
*/
if ($catidList != null) {
$cats = explode(',', $catidList);
$count = count($options);
for ($o = 0; $o < $count; $o++) {
if (!in_array($options[$o]->value, $cats)) {
unset($options[$o]);
}
}
$options = array_values($options);
}
// translate where appropriate
$count = count($options);
for ($o = 0; $o < $count; $o++) {
$options[$o]->text = strpos($options[$o]->text, "JEV_") === 0 ? JText::_($options[$o]->text) : $options[$o]->text;
}
// Thanks to ssobada
// when editing events we restrict the available list!
$jevtask = JRequest::getString("jevtask");
if (strpos($jevtask, "icalevent.edit") !== false || strpos($jevtask, "icalrepeat.edit") !== false) {
$user = JFactory::getUser();
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
$authorisedonly = $params->get("authorisedonly", 0);
if ($authorisedonly) {
$jevuser = JEVHelper::getAuthorisedUser();
if ($jevuser) {
if ($jevuser->categories == "all") {
$cats = array();
foreach ($options as $opt) {
$cats[] = $opt->value;
}
} else {
if ($jevuser->categories != "") {
$cats = explode("|", $jevuser->categories);
} else {
if (JRequest::getInt("evid", 0) > 0) {
// TODO - this should check the creator of the event
$action = 'core.edit';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
$action = 'core.edit.own';
$cats = array_merge($cats, $user->getAuthorisedCategories('com_jevents', $action));
} else {
$action = 'core.create';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
}
}
}
} else {
if (JRequest::getInt("evid", 0) > 0) {
// TODO - this should check the creator of the event
$action = 'core.edit';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
$action = 'core.edit.own';
$cats = array_merge($cats, $user->getAuthorisedCategories('com_jevents', $action));
} else {
$action = 'core.create';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
}
}
} else {
if (JRequest::getInt("evid", 0) > 0) {
// TODO - this should check the creator of the event
$action = 'core.edit';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
$action = 'core.edit.own';
$cats = array_merge($cats, $user->getAuthorisedCategories('com_jevents', $action));
} else {
$action = 'core.create';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
}
}
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onGetAccessibleCategoriesForEditing', array(&$cats));
// allow anon-user event creation through
if (isset($user->id) && $user->id > 0) {
$count = count($options);
//.........这里部分代码省略.........
示例6: importform
function importform()
{
// Can only do this if can add an event
// Must be at least an event creator to edit or create events
$is_event_editor = JEVHelper::isEventCreator();
if (!$is_event_editor) {
$user = JFactory::getUser();
if ($user->id) {
$this->setRedirect(JURI::root(), JText::_('JEV_NOTAUTH_CREATE_EVENT'));
$this->redirect();
} else {
$comuser = version_compare(JVERSION, '1.6.0', '>=') ? "com_users" : "com_user";
$this->setRedirect(JRoute::_("index.php?option={$comuser}&view=login"), JText::_('JEV_NOTAUTH_CREATE_EVENT'));
$this->redirect();
}
return;
}
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
if (!$params->get("feimport", 0)) {
return;
}
$document = JFactory::getDocument();
$viewType = $document->getType();
$cfg = JEVConfig::getInstance();
$theme = JEV_CommonFunctions::getJEventsViewName();
$view = "icals";
$this->addViewPath($this->_basePath . '/' . "views" . '/' . $theme);
$this->view = $this->getView($view, $viewType, $theme . "View", array('base_path' => $this->_basePath, "template_path" => $this->_basePath . '/' . "views" . '/' . $theme . '/' . $view . '/' . 'tmpl', "name" => $theme . '/' . $view));
// Set the layout
$this->view->setLayout('importform');
$this->view->assign("task", $this->_task);
// get all the raw native calendars
$nativeCals = $this->dataModel->queryModel->getNativeIcalendars();
// Strip this list down based on user permissions
$jevuser = JEVHelper::getAuthorisedUser();
if ($jevuser && $jevuser->calendars != "" && $jevuser->calendars != "all") {
$cals = array_keys($nativeCals);
$allowedcals = explode("|", $jevuser->calendars);
foreach ($cals as $calid) {
if (!in_array($calid, $allowedcals)) {
unset($nativeCals[$calid]);
}
}
}
$excats = "0";
if ($jevuser && $jevuser->categories != "" && $jevuser->categories != "all") {
// Find which categories to exclude
$db = JFactory::getDBO();
$catsql = 'SELECT id FROM #__categories WHERE id NOT IN (' . str_replace("|", ",", $jevuser->categories) . ') AND extension="com_jevents"';
$db->setQuery($catsql);
$excats = implode(",", $db->loadColumn());
}
// only offer a choice of native calendars if it exists!
if (count($nativeCals) > 1) {
$icalList = array();
$icalList[] = JHTML::_('select.option', '0', JText::_('JEV_EVENT_CHOOSE_ICAL'), 'ics_id', 'label');
$icalList = array_merge($icalList, $nativeCals);
$clist = JHTML::_('select.genericlist', $icalList, 'icsid', " onchange='preselectCategory(this);'", 'ics_id', 'label', 0);
$this->view->assign('clistChoice', true);
$this->view->assign('defaultCat', 0);
} else {
if (count($nativeCals) == 0 || !is_array($nativeCals)) {
JError::raiseWarning(870, JText::_('INVALID_CALENDAR_STRUCTURE'));
}
$icsid = current($nativeCals)->ics_id;
$clist = '<input type="hidden" name="icsid" value="' . $icsid . '" />';
$this->view->assign('clistChoice', false);
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
if ($params->get("defaultcat", false)) {
$this->view->assign('defaultCat', current($nativeCals)->catid);
} else {
$this->view->assign('defaultCat', 0);
}
}
$this->view->assign('excats', $excats);
$this->view->assign('nativeCals', $nativeCals);
$this->view->assign('clist', $clist);
// View caching logic -- simple... are we logged in?
$cfg = JEVConfig::getInstance();
$joomlaconf = JFactory::getConfig();
$useCache = intval($cfg->get('com_cache', 0)) && $joomlaconf->get('caching', 1);
$user = JFactory::getUser();
if ($user->get('id') || !$useCache) {
$this->view->display();
} else {
$cache = JFactory::getCache(JEV_COM_COMPONENT, 'view');
$cache->get($this->view, 'display');
}
}
示例7: store
/**
* override store function to force rrule to save too!
*
* @param unknown_type $updateNulls
*/
function store($updateNulls = false, $overwriteCreator = false)
{
$user =& JFactory::getUser();
if ($this->ev_id == 0) {
$date =& JevDate::getDate();
$this->created = $date->toMySQL();
}
if (!isset($this->created_by) || is_null($this->created_by) || $this->created_by == 0) {
$this->created_by = $user->id;
}
$this->modified_by = $user->id;
if (!isset($this->created_by_alias) || is_null($this->created_by_alias) || $this->created_by_alias == "") {
$this->created_by_alias = "";
}
// make sure I update existing detail
$matchingDetail = $this->matchingEventDetails();
if (isset($matchingDetail) && isset($matchingDetail->evdet_id)) {
$this->_detail->evdet_id = $matchingDetail->evdet_id;
}
// if existing row preserve created by - unless being overwritten by authorised user
// If user is jevents can deleteall or has backend access then allow them to specify the creator
$jevuser = JEVHelper::getAuthorisedUser();
$creatorid = JRequest::getInt("jev_creatorid", 0);
$access = false;
if ($user->get('id') > 0) {
if (JVersion::isCompatible("1.6.0")) {
//$access = JAccess::check($user->id, "core.deleteall","com_jevents");
$access = $user->authorise('core.deleteall', 'com_jevents');
} else {
// does this logged in have backend access
// Get an ACL object
$acl =& JFactory::getACL();
$grp = $acl->getAroGroup($user->get('id'));
// if no valid group (e.g. anon user) then skip this.
if (!$grp) {
return;
}
$access = $acl->is_group_child_of($grp->name, 'Public Backend');
}
}
if (!($jevuser && $jevuser->candeleteall || $access) || $creatorid == 0) {
if (!is_null($this->ev_id) || $this->ev_id > 0) {
// we can overwrite the creator if refreshing/saving an ical with specified creator
if (isset($matchingDetail) && $matchingDetail->created_by > 0 && !$overwriteCreator) {
$this->created_by = $matchingDetail->created_by;
}
}
}
$db =& JFactory::getDBO();
$detailid = $this->_detail->store($updateNulls);
if (!$detailid) {
JError::raiseError(104, JText::_('PROBLEMS_STORING_EVENT_DETAIL'));
echo $db->getErroMsg() . "<br/>";
return false;
}
$this->detail_id = $detailid;
if (!parent::store($updateNulls)) {
JError::raiseError(105, JText::_('PROBLEMS_STORING_EVENT'));
echo $db->getErrorMsg() . "<br/>";
return false;
}
// I also need to store custom data - when we need the event itself and not just the detail
$dispatcher =& JDispatcher::getInstance();
// just incase we don't have jevents plugins registered yet
JPluginHelper::importPlugin("jevents");
$res = $dispatcher->trigger('onStoreCustomEvent', array(&$this));
if (isset($this->rrule)) {
$this->rrule->eventid = $this->ev_id;
if ($id = $this->rrule->isDuplicate()) {
$this->rrule->rr_id = $id;
}
$this->rrule->store($updateNulls);
echo $db->getErrorMsg() . "<br/>";
}
return true;
}
示例8: canDeleteEvent
/**
* Test to see if user can delete event
*
* @param unknown_type $row
* @param unknown_type $user
* @return unknown
*/
public static function canDeleteEvent($row, $user = null)
{
// store in static to save repeated database calls
static $authdata_coredeleteall = array();
// TODO make this call a plugin
if ($user == null) {
$user = JFactory::getUser();
}
// are we authorised to do anything with this category or calendar
$jevuser = JEVHelper::getAuthorisedUser();
if ($row->_icsid > 0 && $jevuser && $jevuser->calendars != "" && $jevuser->calendars != "all") {
$allowedcals = explode("|", $jevuser->calendars);
if (!in_array($row->_icsid, $allowedcals)) {
return false;
}
}
if ($row->_catid > 0 && $jevuser && $jevuser->categories != "" && $jevuser->categories != "all") {
$allowedcats = explode("|", $jevuser->categories);
if (!in_array($row->_catid, $allowedcats)) {
return false;
}
// check multi cats too
if (JEVHelper::rowCatids($row)) {
if (count(array_diff(JEVHelper::rowCatids($row), $allowedcats))) {
return false;
}
}
}
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
$authorisedonly = $params->get("authorisedonly", 1);
if ($authorisedonly) {
if (!$jevuser) {
return false;
}
if (!is_null($jevuser) && $jevuser->candeleteall) {
return true;
} else {
if (!is_null($jevuser) && $jevuser->candeleteown && $row->created_by() == $user->id) {
return true;
}
}
return false;
}
// This involes TOO many database queries in Joomla - one per category which can be a LOT
/*
$cats = JEVHelper::getAuthorisedCategories($user,'com_jevents', 'core.deleteall');
if (in_array($row->_catid, $cats))
return true;
*/
$key = $row->catids() ? json_encode($row->catids()) : json_encode(intval($row->catid()));
if (!isset($authdata_coredeleteall[$key])) {
$authdata_coredeleteall[$key] = JEVHelper::authoriseCategories('core.deleteall', $key, $user);
}
if ($authdata_coredeleteall[$key]) {
return $authdata_coredeleteall[$key];
}
// can delete all?
if (JEVHelper::isEventDeletor(true)) {
// any category restrictions on this?
// This involes TOO many database queries in Joomla - one per category which can be a LOT
/*
$cats = JEVHelper::getAuthorisedCategories($user,'com_jevents', 'core.deleteall');
if (in_array($row->_catid, $cats))
return true;
*/
$key = $row->catids() ? json_encode($row->catids()) : json_encode(intval($row->catid()));
if (!isset($authdata_coredeleteall[$key])) {
$authdata_coredeleteall[$key] = JEVHelper::authoriseCategories('core.deleteall', $key, $user);
}
if ($authdata_coredeleteall[$key]) {
return $authdata_coredeleteall[$key];
}
}
// There seems to be a problem with category permissions - sometimes Joomla ACL set to yes in category but result is false!
// fall back to being able to delete own events if a publisher
if ($row->created_by() == $user->id) {
$jevuser = JEVHelper::getAuthorisedUser();
if (!is_null($jevuser)) {
return $jevuser->candeleteown;
}
// if a user can publish their own then cal delete their own too
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
$authorisedonly = $params->get("authorisedonly", 1);
$publishown = $params->get("jevpublishown", 0);
if (!$authorisedonly && ($publishown || JEVHelper::canPublishEvent($row, $user))) {
return true;
}
}
return false;
}
示例9: store
/**
* override store function to force rrule to save too!
*
* @param unknown_type $updateNulls
*/
function store($updateNulls = false, $overwriteCreator = false)
{
$user = JFactory::getUser();
if ($this->ev_id == 0) {
$date = JevDate::getDate("+0 seconds");
$this->created = $date->toMySQL();
}
if (!isset($this->created_by) || is_null($this->created_by) || $this->created_by == 0) {
$this->created_by = $user->id;
}
$this->modified_by = $user->id;
if (!isset($this->created_by_alias) || is_null($this->created_by_alias) || $this->created_by_alias == "") {
$this->created_by_alias = "";
}
// make sure I update existing detail
$matchingDetail = $this->matchingEventDetails();
if (isset($matchingDetail) && isset($matchingDetail->evdet_id)) {
$this->_detail->evdet_id = $matchingDetail->evdet_id;
}
// if existing row preserve created by - unless being overwritten by authorised user
// If user is jevents can deleteall or has backend access then allow them to specify the creator
$jevuser = JEVHelper::getAuthorisedUser();
$creatorid = JRequest::getInt("jev_creatorid", 0);
$access = false;
if ($user->get('id') > 0) {
//$access = JAccess::check($user->id, "core.deleteall","com_jevents");
$access = $user->authorise('core.deleteall', 'com_jevents');
}
if (!($jevuser && $jevuser->candeleteall || $access) || $creatorid == 0) {
if (!is_null($this->ev_id) || $this->ev_id > 0) {
// we can overwrite the creator if refreshing/saving an ical with specified creator
if (isset($matchingDetail) && $matchingDetail->created_by > 0 && !$overwriteCreator) {
$this->created_by = $matchingDetail->created_by;
}
}
}
// place private reference to created_by in event detail in case needed by plugins
$this->_detail->_created_by = $this->created_by;
$db = JFactory::getDBO();
$detailid = $this->_detail->store($updateNulls);
if (!$detailid) {
JError::raiseError(104, JText::_('PROBLEMS_STORING_EVENT_DETAIL'));
echo $db->getErrorMsg() . "<br/>";
return false;
}
$this->detail_id = $detailid;
// Keep the multiple catids for storing after this
$catids = false;
if (is_array($this->catid)) {
$catids = $this->catid;
$this->catid = $this->catid[0];
}
if (!parent::store($updateNulls)) {
JError::raiseError(105, JText::_('PROBLEMS_STORING_EVENT'));
echo $db->getErrorMsg() . "<br/>";
return false;
}
if ($catids) {
$pairs = array();
$order = 0;
foreach ($catids as $catid) {
if ($catid == "") {
$catid = -1;
} else {
$pairs[] = "({$this->ev_id},{$catid}, {$order})";
$order++;
}
}
$db->setQuery("DELETE FROM #__jevents_catmap where evid = " . $this->ev_id . " AND catid NOT IN (" . implode(",", $catids) . ")");
$sql = $db->getQuery();
$success = $db->query();
if (count($pairs) > 0) {
$db->setQuery("Replace into #__jevents_catmap (evid, catid, ordering) VALUES " . implode(",", $pairs));
$sql = $db->getQuery();
$success = $db->query();
}
}
// I also need to store custom data - when we need the event itself and not just the detail
$dispatcher = JDispatcher::getInstance();
// just incase we don't have jevents plugins registered yet
JPluginHelper::importPlugin("jevents");
$res = $dispatcher->trigger('onStoreCustomEvent', array(&$this));
if (isset($this->rrule)) {
$this->rrule->eventid = $this->ev_id;
if ($id = $this->rrule->isDuplicate()) {
$this->rrule->rr_id = $id;
}
$this->rrule->store($updateNulls);
echo $db->getErrorMsg() . "<br/>";
}
return true;
}
示例10: buildCategorySelect
/**
* Build HTML selection list of categories
*
* @param int $catid Selected catid
* @param string $args Additional HTML attributes for the <select> tag
* @param string $catidList Restriction list of categories
* @param boolean $with_unpublished Set true to build list with unpublished categories
* @param boolean $require_sel First entry: true = Choose one category, false = All categories
* @param int $catidtop Top level category ancestor
*/
function buildCategorySelect($catid, $args, $catidList = null, $with_unpublished = false, $require_sel = false, $catidtop = 0, $fieldname = "catid", $sectionname = JEV_COM_COMPONENT, $excludeid = false, $order = "ordering", $eventediting = false)
{
if (JVersion::isCompatible("1.6.0")) {
// need to declare this because of bug in Joomla JHtml::_('select.options', on content pages - it loade the WRONG CLASS!
include_once JPATH_SITE . "/libraries/joomla/html/html/category.php";
ob_start();
$t_first_entry = $require_sel ? JText::_('JEV_EVENT_CHOOSE_CATEG') : JText::_('JEV_EVENT_ALLCAT');
$options = JHtml::_('category.options', $sectionname);
if ($catidList != null) {
$cats = explode(',', $catidList);
$count = count($options);
for ($o = 0; $o < $count; $o++) {
if (!in_array($options[$o]->value, $cats)) {
unset($options[$o]);
}
}
$options = array_values($options);
}
// Thanks to ssobada
// when editing events we restrict the available list!
$jevtask = JRequest::getString("jevtask");
if (strpos($jevtask, "icalevent.edit") !== false || strpos($jevtask, "icalrepeat.edit") !== false) {
$user = JFactory::getUser();
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
$authorisedonly = $params->get("authorisedonly", 0);
if ($authorisedonly) {
$jevuser = JEVHelper::getAuthorisedUser();
if ($jevuser) {
if ($jevuser->categories == "all") {
$cats = array();
foreach ($options as $opt) {
$cats[] = $opt->value;
}
} else {
if ($jevuser->categories != "") {
$cats = explode("|", $jevuser->categories);
} else {
if (JRequest::getInt("evid", 0) > 0) {
// TODO - this should check the creator of the event
$action = 'core.edit';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
$action = 'core.edit.own';
$cats = array_merge($cats, $user->getAuthorisedCategories('com_jevents', $action));
} else {
$action = 'core.create';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
}
}
}
} else {
if (JRequest::getInt("evid", 0) > 0) {
// TODO - this should check the creator of the event
$action = 'core.edit';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
$action = 'core.edit.own';
$cats = array_merge($cats, $user->getAuthorisedCategories('com_jevents', $action));
} else {
$action = 'core.create';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
}
}
} else {
if (JRequest::getInt("evid", 0) > 0) {
// TODO - this should check the creator of the event
$action = 'core.edit';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
$action = 'core.edit.own';
$cats = array_merge($cats, $user->getAuthorisedCategories('com_jevents', $action));
} else {
$action = 'core.create';
$cats = $user->getAuthorisedCategories('com_jevents', $action);
}
}
$dispatcher =& JDispatcher::getInstance();
$dispatcher->trigger('onGetAccessibleCategoriesForEditing', array(&$cats));
// allow anon-user event creation through
if (isset($user->id)) {
$count = count($options);
for ($o = 0; $o < $count; $o++) {
if (!in_array($options[$o]->value, $cats)) {
unset($options[$o]);
}
}
$options = array_values($options);
}
} else {
}
// if only one category then preselect it
if (count($options) == 1) {
$catid = current($options)->value;
//.........这里部分代码省略.........
示例11: canDeleteEvent
/**
* Test to see if user can delete event
*
* @param unknown_type $row
* @param unknown_type $user
* @return unknown
*/
function canDeleteEvent($row, $user = null)
{
// TODO make this call a plugin
if ($user == null) {
$user =& JFactory::getUser();
}
// are we authorised to do anything with this category or calendar
$jevuser =& JEVHelper::getAuthorisedUser();
if ($row->_icsid > 0 && $jevuser && $jevuser->calendars != "" && $jevuser->calendars != "all") {
$allowedcals = explode("|", $jevuser->calendars);
if (!in_array($row->_icsid, $allowedcals)) {
return false;
}
}
if ($row->_catid > 0 && $jevuser && $jevuser->categories != "" && $jevuser->categories != "all") {
$allowedcats = explode("|", $jevuser->categories);
if (!in_array($row->_catid, $allowedcats)) {
return false;
}
}
if (JVersion::isCompatible("1.6.0")) {
$cats = $user->getAuthorisedCategories('com_jevents', 'core.edit.state');
if (in_array($row->_catid, $cats)) {
return true;
}
}
// can publish all?
if (JEVHelper::isEventDeletor(true)) {
return true;
} else {
if ($row->created_by() == $user->id) {
$jevuser =& JEVHelper::getAuthorisedUser();
if (!is_null($jevuser)) {
return $jevuser->candeleteown;
}
// if a user can publish their own then cal delete their own too
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
$authorisedonly = $params->get("authorisedonly", 1);
$publishown = $params->get("jevpublishown", 0);
if (!$authorisedonly && $publishown) {
return true;
}
}
}
return false;
}
示例12: ProcessJsonRequest
/**
* @copyright Copyright (C) 2015-2015 GWE Systems Ltd. All rights reserved.
* @license By negoriation with author via http://www.gwesystems.com
*/
function ProcessJsonRequest(&$requestObject, $returnData)
{
$returnData->titles = array();
$returnData->exactmatch = false;
ini_set("display_errors", 0);
include_once JPATH_SITE . "/components/com_jevents/jevents.defines.php";
$token = JSession::getFormToken();
if (isset($requestObject->token) && $requestObject->token != $token || JFactory::getApplication()->input->get('token', '', 'string') != $token) {
PlgSystemGwejson::throwerror("There was an error - bad token. Please refresh the page and try again.");
}
$user = JFactory::getUser();
if ($user->id == 0) {
PlgSystemGwejson::throwerror("There was an error");
}
// If user is jevents can deleteall or has backend access then allow them to specify the creator
$jevuser = JEVHelper::getAuthorisedUser();
$user = JFactory::getUser();
//$access = JAccess::check($user->id, "core.deleteall", "com_jevents");
$access = $user->authorise('core.admin', 'com_jevents') || $user->authorise('core.deleteall', 'com_jevents');
$db = JFactory::getDBO();
if (!($jevuser && $jevuser->candeleteall) && !$access) {
PlgSystemGwejson::throwerror("There was an error - no access");
}
if ($requestObject->error) {
return "Error";
}
if (isset($requestObject->typeahead) && trim($requestObject->typeahead) !== "") {
$returnData->result = "title is " . $requestObject->typeahead;
} else {
PlgSystemGwejson::throwerror("There was an error - no valid argument");
}
$db = JFactory::getDBO();
$title = JFilterInput::getInstance()->clean($requestObject->typeahead, "string");
$text = $db->Quote('%' . $db->escape($title, true) . '%', false);
// Remove any dodgy characters from fields
// Only allow a to z , 0 to 9, ', " space (\\040), hyphen (\\-), underscore (\\_)
/*
$regex = '/[^a-zA-Z0-9_\'\"\'\\40\\-\\_]/';
$title = preg_replace($regex, "", $title);
$title = JString::substr($title." ",0,4);
*/
if (trim($title) == "" && trim($title) == "") {
PlgSystemGwejson::throwerror("There was an error - no valid argument");
}
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
$authorisedonly = $params->get("authorisedonly", 0);
// if authorised only then load from database
if ($authorisedonly) {
$sql = "SELECT ju.* FROM #__jev_users AS tl ";
$sql .= " LEFT JOIN #__users as ju ON tl.user_id=ju.id ";
$sql .= " WHERE tl.cancreate=1 and ju.username LIKE ({$text}) OR ju.name LIKE ({$text}) ";
$sql .= " ORDER BY ju.name ASC";
$sql .= " LIMIT 500";
$db->setQuery($sql);
$matches = $db->loadObjectList();
} else {
$rules = JAccess::getAssetRules("com_jevents", true);
$creatorgroups = $rules->getData();
// need to merge the arrays because of stupid way Joomla checks super user permissions
//$creatorgroups = array_merge($creatorgroups["core.admin"]->getData(), $creatorgroups["core.create"]->getData());
// use union orf arrays sincee getData no longer has string keys in the resultant array
//$creatorgroups = $creatorgroups["core.admin"]->getData()+ $creatorgroups["core.create"]->getData();
// use union orf arrays sincee getData no longer has string keys in the resultant array
$creatorgroupsdata = $creatorgroups["core.admin"]->getData();
// take the higher permission setting
foreach ($creatorgroups["core.create"]->getData() as $creatorgroup => $permission) {
if ($permission) {
$creatorgroupsdata[$creatorgroup] = $permission;
}
}
$userids = array(0);
foreach ($creatorgroupsdata as $creatorgroup => $permission) {
if ($permission == 1) {
$userids = array_merge(JAccess::getUsersByGroup($creatorgroup, true), $userids);
}
}
$sql = "SELECT * FROM #__users " . "where id IN (" . implode(",", array_values($userids)) . ") and username LIKE ({$text}) OR name LIKE ({$text}) and block=0 " . "ORDER BY name asc LIMIT 500";
$db->setQuery($sql);
$matches = $db->loadObjectList();
}
if (count($matches) == 0) {
$returnData = array();
} else {
$returnData = array();
foreach ($matches as $match) {
$result = new stdClass();
$result->title = $match->name . " (" . $match->username . ")";
$result->creator_id = $match->id;
$returnData[] = $result;
}
}
return $returnData;
}
示例13: getInput
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
$maxDirectNumber = 50;
JLoader::register('JEVHelper', JPATH_SITE . "/components/com_jevents/libraries/helper.php");
JEVHelper::ConditionalFields($this->element, $this->form->getName());
$creator = intval($this->value) > 0 ? intval($this->value) : (isset($user) ? $user->id : 0);
// If user is jevents can deleteall or has backend access then allow them to specify the creator
$jevuser = JEVHelper::getAuthorisedUser();
$user = JFactory::getUser();
//$access = JAccess::check($user->id, "core.deleteall", "com_jevents");
$access = $user->authorise('core.admin', 'com_jevents') || $user->authorise('core.deleteall', 'com_jevents');
$db = JFactory::getDBO();
if ($jevuser && $jevuser->candeleteall || $access) {
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
$authorisedonly = $params->get("authorisedonly", 0);
// if authorised only then load from database
if ($authorisedonly) {
$sql = "SELECT count(tl.id) FROM #__jev_users AS tl ";
$sql .= " LEFT JOIN #__users as ju ON tl.user_id=ju.id ";
$sql .= " WHERE tl.cancreate=1";
$sql .= " ORDER BY ju.name ASC";
$db->setQuery($sql);
$userCount = $db->loadResult();
if ($userCount <= $maxDirectNumber) {
$sql = "SELECT tl.*, ju.* FROM #__jev_users AS tl ";
$sql .= " LEFT JOIN #__users as ju ON tl.user_id=ju.id ";
$sql .= " WHERE tl.cancreate=1";
$sql .= " ORDER BY ju.name ASC";
$db->setQuery($sql);
$users = $db->loadObjectList();
}
} else {
$rules = JAccess::getAssetRules("com_jevents", true);
$creatorgroups = $rules->getData();
// need to merge the arrays because of stupid way Joomla checks super user permissions
//$creatorgroups = array_merge($creatorgroups["core.admin"]->getData(), $creatorgroups["core.create"]->getData());
// use union orf arrays sincee getData no longer has string keys in the resultant array
//$creatorgroups = $creatorgroups["core.admin"]->getData()+ $creatorgroups["core.create"]->getData();
// use union orf arrays sincee getData no longer has string keys in the resultant array
$creatorgroupsdata = $creatorgroups["core.admin"]->getData();
// take the higher permission setting
foreach ($creatorgroups["core.create"]->getData() as $creatorgroup => $permission) {
if ($permission) {
$creatorgroupsdata[$creatorgroup] = $permission;
}
}
$userids = array(0);
foreach ($creatorgroupsdata as $creatorgroup => $permission) {
if ($permission == 1) {
$userids = array_merge(JAccess::getUsersByGroup($creatorgroup, true), $userids);
}
}
$sql = "SELECT count(id) FROM #__users where id IN (" . implode(",", array_values($userids)) . ") and block=0 ORDER BY name asc";
$db->setQuery($sql);
$userCount = $db->loadResult();
if ($userCount <= $maxDirectNumber) {
$sql = "SELECT * FROM #__users where id IN (" . implode(",", array_values($userids)) . ") and block=0 ORDER BY name asc";
$db->setQuery($sql);
$users = $db->loadObjectList();
}
}
// get list of creators - if fewer than 200
if (!isset($users)) {
// Use Typeahead instead
if ($userCount > $maxDirectNumber) {
$creatorname = "";
if ($creator > 0) {
$sql = "SELECT * FROM #__users where id = {$creator}";
$db->setQuery($sql);
$creatorData = $db->loadObject();
if ($creatorData) {
$creatorname = $creatorData->name . " (" . $creatorData->username . ")";
}
}
ob_start();
?>
<input type="hidden" name='jev_creatorid' id='jev_creatorid' value="<?php
echo $creator;
?>
"/>
<div id="scrollable-dropdown-menu" style="float:left">
<input name="creatorid_notused" id="ta_creatorid" class="jevtypeahead" placeholder="<?php
echo $creatorname;
?>
" type="text" autocomplete="off" size="50">
</div>
<?php
JLoader::register('JevTypeahead', JPATH_LIBRARIES . "/jevents/jevtypeahead/jevtypeahead.php");
$datapath = JRoute::_("index.php?option=com_jevents&ttoption=com_jevents&typeaheadtask=gwejson&file=findcreator", false);
//$prefetchdatapath = JRoute::_("index.php?option=com_jevents&ttoption=com_jevents&typeaheadtask=gwejson&file=findcreator&prefetch=1", false);
JevTypeahead::typeahead('#ta_creatorid', array('remote' => $datapath, 'data_value' => 'title', 'data_id' => 'creator_id', 'field_selector' => '#jev_creatorid', 'minLength' => 2, 'limit' => 10, 'scrollable' => 1));
return ob_get_clean();
}
return "";
//.........这里部分代码省略.........