本文整理汇总了PHP中JEVHelper::canPublishOwnEvents方法的典型用法代码示例。如果您正苦于以下问题:PHP JEVHelper::canPublishOwnEvents方法的具体用法?PHP JEVHelper::canPublishOwnEvents怎么用?PHP JEVHelper::canPublishOwnEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JEVHelper
的用法示例。
在下文中一共展示了JEVHelper::canPublishOwnEvents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: toggleICalEventPublish
protected function toggleICalEventPublish($cid, $newstate)
{
// clean out the cache
$cache =& JFactory::getCache('com_jevents');
$cache->clean(JEV_COM_COMPONENT);
// Must be at least an event creator to publish events
$is_event_editor = JEVHelper::isEventPublisher();
if (!$is_event_editor) {
if (is_array($cid)) {
foreach ($cid as $id) {
if (!JEVHelper::canPublishOwnEvents($id)) {
JError::raiseError(403, JText::_('ALERTNOTAUTH'));
}
}
}
$is_event_editor = true;
}
if (!$is_event_editor) {
JError::raiseError(403, JText::_('ALERTNOTAUTH'));
}
$db =& JFactory::getDBO();
foreach ($cid as $id) {
// I should be able to do this in one operation but that can come later
$event = $this->queryModel->getEventById(intval($id), 1, "icaldb");
if (is_null($event) || !JEVHelper::canPublishEvent($event)) {
JError::raiseError(403, JText::_('ALERTNOTAUTH'));
}
$sql = "UPDATE #__jevents_vevent SET state={$newstate} where ev_id='" . $id . "'";
$db->setQuery($sql);
$db->query();
$params = JComponentHelper::getParams(JEV_COM_COMPONENT);
if ($newstate == 1 && $params->get("com_notifyauthor", 0) && !$event->_author_notified) {
$sql = "UPDATE #__jevents_vevent SET author_notified=1 where ev_id='" . $id . "'";
$db->setQuery($sql);
$db->query();
JEV_CommonFunctions::notifyAuthorPublished($event);
}
}
// I also need to trigger any onpublish event triggers
$dispatcher =& JDispatcher::getInstance();
// just incase we don't have jevents plugins registered yet
JPluginHelper::importPlugin("jevents");
$res = $dispatcher->trigger('onPublishEvent', array($cid, $newstate));
if (JFactory::getApplication()->isAdmin()) {
$this->setRedirect('index.php?option=' . JEV_COM_COMPONENT . '&task=icalevent.list', "IcalEvent : New published state Saved");
} else {
$Itemid = JRequest::getInt("Itemid");
list($year, $month, $day) = JEVHelper::getYMD();
$rettask = JRequest::getString("rettask", "day.listevents");
// Don't return to the event detail since we may be filtering on published state!
//$this->setRedirect( JRoute::_('index.php?option=' . JEV_COM_COMPONENT. "&task=icalrepeat.detail&evid=$id&year=$year&month=$month&day=$day&Itemid=$Itemid",false),"IcalEvent : New published state Saved");
$this->setRedirect(JRoute::_('index.php?option=' . JEV_COM_COMPONENT . "&task={$rettask}&year={$year}&month={$month}&day={$day}&Itemid={$Itemid}", false), "IcalEvent : New published state Saved");
}
}