本文整理汇总了PHP中CostbenefitprojectionHelper::checkIntervetionAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP CostbenefitprojectionHelper::checkIntervetionAccess方法的具体用法?PHP CostbenefitprojectionHelper::checkIntervetionAccess怎么用?PHP CostbenefitprojectionHelper::checkIntervetionAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CostbenefitprojectionHelper
的用法示例。
在下文中一共展示了CostbenefitprojectionHelper::checkIntervetionAccess方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVwfinterventions
/**
* Method to get list data.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getVwfinterventions()
{
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the costbenefitprojection_intervention table
$query->from($db->quoteName('#__costbenefitprojection_intervention', 'a'));
// Filter the companies (admin sees all)
if (!$user->authorise('core.options', 'com_costbenefitprojection')) {
$companies = CostbenefitprojectionHelper::hisCompanies($user->id);
if (CostbenefitprojectionHelper::checkArray($companies)) {
$companies = implode(',', $companies);
// only load this users companies
$query->where('a.company IN (' . $companies . ')');
} else {
// don't allow user to see any companies
$query->where('a.company = -4');
}
}
// From the costbenefitprojection_company table.
$query->select($db->quoteName('g.name', 'company_name'));
$query->join('LEFT', $db->quoteName('#__costbenefitprojection_company', 'g') . ' ON (' . $db->quoteName('a.company') . ' = ' . $db->quoteName('g.id') . ')');
// Filter by countryvvvy global.
$countryvvvy = $this->countryvvvy;
if (is_numeric($countryvvvy)) {
$query->where('a.country = ' . (int) $countryvvvy);
} elseif (is_string($countryvvvy)) {
$query->where('a.country = ' . $db->quote($countryvvvy));
} else {
$query->where('a.country = -5');
}
// Order the results by ordering
$query->order('a.published ASC');
$query->order('a.ordering ASC');
// Load the items
$db->setQuery($query);
$db->execute();
if ($db->getNumRows()) {
$items = $db->loadObjectList();
// set values to display correctly.
if (CostbenefitprojectionHelper::checkArray($items)) {
// get user object.
$user = JFactory::getUser();
foreach ($items as $nr => &$item) {
$access = $user->authorise('intervention.access', 'com_costbenefitprojection.intervention.' . (int) $item->id) && $user->authorise('intervention.access', 'com_costbenefitprojection');
if (!$access) {
unset($items[$nr]);
continue;
}
}
}
// check if item is to load based on sharing setting
if (CostbenefitprojectionHelper::checkArray($items)) {
foreach ($items as $nr => &$item) {
if (!CostbenefitprojectionHelper::checkIntervetionAccess($item->id, $item->share, $item->company)) {
unset($items[$nr]);
continue;
}
}
}
// set selection value to a translatable value
if (CostbenefitprojectionHelper::checkArray($items)) {
foreach ($items as $nr => &$item) {
// convert type
$item->type = $this->selectionTranslationVwfinterventions($item->type, 'type');
}
}
return $items;
}
return false;
}
示例2: getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
public function getOptions()
{
// get the input from url
$jinput = JFactory::getApplication()->input;
// get the view name & id
$interId = $jinput->getInt('id', 0);
// Get the user object.
$user = JFactory::getUser();
$userIs = CostbenefitprojectionHelper::userIs($user->id);
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id', 'a.name', 'a.company', 'a.share'), array('id', 'interventions_name', 'company', 'share')));
$query->from($db->quoteName('#__costbenefitprojection_intervention', 'a'));
$query->where($db->quoteName('a.published') . ' = 1');
$query->where($db->quoteName('a.id') . ' != ' . $interId);
if (!$user->authorise('core.admin')) {
$companies = CostbenefitprojectionHelper::hisCompanies($user->id);
if (CostbenefitprojectionHelper::checkArray($companies)) {
$companies = implode(',', $companies);
// only load this users companies
$query->where('a.company IN (' . $companies . ')');
} else {
// dont allow user to see any companies
$query->where('a.company = -4');
}
}
$query->order('a.name ASC');
$db->setQuery((string) $query);
$items = $db->loadObjectList();
$options = array();
if ($items) {
foreach ($items as $item) {
if (!CostbenefitprojectionHelper::checkIntervetionAccess($item->id, $item->share, $item->company)) {
continue;
}
if (1 == $userIs) {
$options[] = JHtml::_('select.option', $item->id, $item->interventions_name);
} else {
$compName = CostbenefitprojectionHelper::getId('company', $item->company, 'id', 'name');
$options[] = JHtml::_('select.option', $item->id, $item->interventions_name . ' (' . $compName . ')');
}
}
}
return $options;
}
示例3: batchMove
/**
* Batch move items to a new category
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 12.2
*/
protected function batchMove($values, $pks, $contexts)
{
if (empty($this->batchSet)) {
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType();
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
$this->canDo = CostbenefitprojectionHelper::getActions('intervention');
}
if (!$this->canDo->get('intervention.edit') && !$this->canDo->get('intervention.batch')) {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// set company array
$company = array();
foreach ($pks as $nr => $pk) {
$company[$pk] = CostbenefitprojectionHelper::getId('intervention', $pk, 'id', 'company');
// check based on sharing option
if (!CostbenefitprojectionHelper::checkIntervetionAccess($pk, null, $company[$pk])) {
unset($pks[$nr]);
}
}
if (empty($pks)) {
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', 0));
return false;
}
// admin can all
if (!$this->user->authorise('core.options', 'com_costbenefitprojection')) {
// make absolutely sure that this intervention can be moved
$companies = CostbenefitprojectionHelper::hisCompanies($this->user->id);
if (CostbenefitprojectionHelper::checkArray($companies)) {
foreach ($pks as $nr => $pk) {
if (!in_array($company[$pk], $companies)) {
unset($pks[$nr]);
}
}
if (empty($pks)) {
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', 0));
return false;
}
} else {
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', 0));
return false;
}
}
// make sure published only updates if user has the permission.
if (isset($values['published']) && !$this->canDo->get('intervention.edit.state')) {
unset($values['published']);
}
// remove move_copy from array
unset($values['move_copy']);
// Parent exists so we proceed
foreach ($pks as $pk) {
if (!$this->user->authorise('intervention.edit', $contexts[$pk])) {
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
// Check that the row actually exists
if (!$this->table->load($pk)) {
if ($error = $this->table->getError()) {
// Fatal error
$this->setError($error);
return false;
} else {
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// insert all set values.
if (CostbenefitprojectionHelper::checkArray($values)) {
foreach ($values as $key => $value) {
// Do special action for access.
if ('access' == $key && strlen($value) > 0) {
$this->table->{$key} = $value;
} elseif (strlen($value) > 0 && isset($this->table->{$key})) {
$this->table->{$key} = $value;
}
}
}
// Check the row.
if (!$this->table->check()) {
$this->setError($this->table->getError());
return false;
}
if (!empty($this->type)) {
$this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
//.........这里部分代码省略.........
示例4: getExportData
/**
* Method to get list export data.
*
* @return mixed An array of data items on success, false on failure.
*/
public function getExportData($pks)
{
// setup the query
if (CostbenefitprojectionHelper::checkArray($pks)) {
// Set a value to know this is exporting method.
$_export = true;
// Get the user object.
$user = JFactory::getUser();
// Create a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select('a.*');
// From the costbenefitprojection_intervention table
$query->from($db->quoteName('#__costbenefitprojection_intervention', 'a'));
$query->where('a.id IN (' . implode(',', $pks) . ')');
// Filter the companies (admin sees all)
if (!$user->authorise('core.options', 'com_costbenefitprojection')) {
$companies = CostbenefitprojectionHelper::hisCompanies($user->id);
if (CostbenefitprojectionHelper::checkArray($companies)) {
$companies = implode(',', $companies);
// only load this users companies
$query->where('a.company IN (' . $companies . ')');
} else {
// don't allow user to see any companies
$query->where('a.company = -4');
}
}
// Order the results by ordering
$query->order('a.ordering ASC');
// Load the items
$db->setQuery($query);
$db->execute();
if ($db->getNumRows()) {
$items = $db->loadObjectList();
// set values to display correctly.
if (CostbenefitprojectionHelper::checkArray($items)) {
// get user object.
$user = JFactory::getUser();
foreach ($items as $nr => &$item) {
$access = $user->authorise('intervention.access', 'com_costbenefitprojection.intervention.' . (int) $item->id) && $user->authorise('intervention.access', 'com_costbenefitprojection');
if (!$access) {
unset($items[$nr]);
continue;
}
// unset the values we don't want exported.
unset($item->asset_id);
unset($item->checked_out);
unset($item->checked_out_time);
}
}
// Add headers to items array.
$headers = $this->getExImPortHeaders();
if (CostbenefitprojectionHelper::checkObject($headers)) {
array_unshift($items, $headers);
}
// check if item is to load based on sharing setting
if (CostbenefitprojectionHelper::checkArray($items)) {
foreach ($items as $nr => &$item) {
if (!CostbenefitprojectionHelper::checkIntervetionAccess($item->id, $item->share, $item->company)) {
unset($items[$nr]);
continue;
}
}
}
return $items;
}
}
return false;
}
示例5: allowEdit
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowEdit($data = array(), $key = 'id')
{
// get user object.
$user = JFactory::getUser();
// get record id.
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
// get company id
$company = CostbenefitprojectionHelper::getId('intervention', $recordId, 'id', 'company');
if (!$user->authorise('core.options', 'com_costbenefitprojection')) {
// make absolutely sure that this intervention can be edited
$companies = CostbenefitprojectionHelper::hisCompanies($user->id);
if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($company, $companies)) {
return false;
}
}
// now check the access by sharing
if (!CostbenefitprojectionHelper::checkIntervetionAccess($recordId, null, $company)) {
return false;
}
// Access check.
$access = $user->authorise('intervention.access', 'com_costbenefitprojection.intervention.' . (int) $recordId) && $user->authorise('intervention.access', 'com_costbenefitprojection');
if (!$access) {
return false;
}
if ($recordId) {
// The record has been set. Check the record permissions.
$permission = $user->authorise('intervention.edit', 'com_costbenefitprojection.intervention.' . (int) $recordId);
if (!$permission && !is_null($permission)) {
if ($user->authorise('intervention.edit.own', 'com_costbenefitprojection.intervention.' . $recordId)) {
// Now test the owner is the user.
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
if (empty($ownerId)) {
// Need to do a lookup from the model.
$record = $this->getModel()->getItem($recordId);
if (empty($record)) {
return false;
}
$ownerId = $record->created_by;
}
// If the owner matches 'me' then allow.
if ($ownerId == $user->id) {
if ($user->authorise('intervention.edit.own', 'com_costbenefitprojection')) {
return true;
}
}
}
return false;
}
}
// Since there is no permission, revert to the component permissions.
return $user->authorise('intervention.edit', $this->option);
}