本文整理汇总了PHP中PFApplicationHelper::usesProjectAsset方法的典型用法代码示例。如果您正苦于以下问题:PHP PFApplicationHelper::usesProjectAsset方法的具体用法?PHP PFApplicationHelper::usesProjectAsset怎么用?PHP PFApplicationHelper::usesProjectAsset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PFApplicationHelper
的用法示例。
在下文中一共展示了PFApplicationHelper::usesProjectAsset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItem
/**
* Method to get item data.
*
* @param integer The id of the item.
*
* @return mixed Record object on success, false on failure.
*/
public function getItem($pk = null)
{
// Initialise variables.
$pk = !empty($pk) ? $pk : (int) $this->getState($this->getName() . '.id');
if ($this->_item === null) {
$this->_item = array();
}
if (isset($this->_item[$pk])) {
return $this->_item[$pk];
}
$cfg = JComponentHelper::getParams('com_pfprojects');
$create_group = (int) $cfg->get('create_group');
$group_location = (int) $cfg->get('group_location');
$inherit = $this->getState($this->getName() . '.inherit');
if (!$group_location) {
$group_location = 1;
}
try {
$db = $this->getDbo();
$query = $db->getQuery(true);
if (!$inherit && !$pk && $create_group) {
$item = new stdClass();
$item->id = 0;
$item->parent_id = $group_location;
$item->lft = 0;
$item->rgt = 0;
$item->title = JText::_('COM_PFUSERS_DEFAULT_GROUP');
} else {
$query->select('id, parent_id, lft, rgt, title')->from('#__usergroups')->where('id = ' . (int) $pk);
$db->setQuery($query);
$item = $db->loadObject();
}
if ($error = $db->getErrorMsg()) {
throw new Exception($error);
}
$this->_item[$pk] = empty($item) ? false : $item;
if ($this->_item[$pk]) {
if (!$inherit) {
$component = $this->getState($this->getName() . '.component');
$section = $this->getState($this->getName() . '.section');
$this->_item[$pk]->actions = array();
$this->_item[$pk]->actions[$component] = JAccess::getActions($component, $section);
$components = PFApplicationHelper::getComponents();
foreach ($components as $name => $item) {
if ($name == $component) {
continue;
}
$use_asset = PFApplicationHelper::usesProjectAsset($name);
$enabled = PFApplicationHelper::enabled($name);
if (!$use_asset || !$enabled) {
continue;
}
$this->_item[$pk]->actions[$name] = JAccess::getActions($name, $section);
}
// Get child group names
if ($this->_item[$pk]->lft && $this->_item[$pk]->rgt) {
$this->_item[$pk]->children = $this->getChildGroups($this->_item[$pk]->lft, $this->_item[$pk]->rgt);
} else {
$this->_item[$pk]->children = array();
}
} else {
$component = $this->getState($this->getName() . '.component');
$section = $this->getState($this->getName() . '.section');
$this->_item[$pk]->actions = JAccess::getActions($component, $section);
// Get child group names
if ($this->_item[$pk]->lft && $this->_item[$pk]->rgt) {
$this->_item[$pk]->children = $this->getChildGroups($this->_item[$pk]->lft, $this->_item[$pk]->rgt);
} else {
$this->_item[$pk]->children = array();
}
}
}
} catch (JException $e) {
if ($e->getCode() == 404) {
// Need to go thru the error handler to allow Redirect to work.
JError::raiseError(404, $e->getMessage());
} else {
$this->setError($e);
$this->_item[$pk] = false;
}
}
return $this->_item[$pk];
}
示例2: checkProjectAssets
protected function checkProjectAssets()
{
$this->project_assets = array();
$db = $this->getDbo();
$query = $db->getQuery(true);
foreach ($this->components as $name => $item) {
$use_asset = PFApplicationHelper::usesProjectAsset($name);
if (!$use_asset || !isset($this->root_assets[$name]) || empty($this->root_assets[$name])) {
continue;
}
$query->clear()->select('*')->from('#__assets')->where('name = ' . $db->quote($name . '.project.' . $this->project->id));
$db->setQuery($query);
$asset = $db->loadObject();
if (!empty($asset)) {
if ($asset->parent_id != $this->root_assets[$name]->id) {
$id = $asset->id;
$asset = JTable::getInstance('Asset', 'JTable', array('dbo' => $db));
$asset->load($id);
$asset->setLocation($this->root_assets[$name]->id, 'first-child');
$asset->parent_id = $this->root_assets[$name]->id;
if (!$asset->check() || !$asset->store(false)) {
continue;
}
}
$this->project_assets[$name] = $asset;
continue;
}
$asset = JTable::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
$asset->setLocation($this->root_assets[$name]->id, 'first-child');
$asset->parent_id = $this->root_assets[$name]->id;
$asset->name = $name . '.project.' . $this->project->id;
$asset->title = $this->project->title;
$asset->rules = $this->root_assets[$name]->rules;
if (!$asset->check() || !$asset->store(false)) {
continue;
}
$this->project_assets[$name] = $asset;
}
return true;
}
示例3: storeComponentAssets
/**
* Method to store the project asset for the other PF components
*
* @param mixed $pk An optional primary key value to delete.
*
* @return boolean True on success.
*/
public function storeComponentAssets($pk = null)
{
$k = $this->_tbl_key;
$pk = is_null($pk) ? $this->{$k} : $pk;
if (!$pk) {
return false;
}
$components = PFApplicationHelper::getComponents();
$query = $this->_db->getQuery(true);
$ignore = array('com_projectfork', 'com_pfprojects');
// First, find the asset id's of each component
// Then, search for corresponding project asset
// And lastly, create the project asset if it does not exist
foreach ($components as $name => $item) {
if (!PFApplicationHelper::usesProjectAsset($name)) {
continue;
}
// Search component asset
$query->clear();
$query->select('id')->from('#__assets')->where('name = ' . $this->_db->quote($name))->order('id ASC');
$this->_db->setQuery($query, 0, 1);
$com_asset = (int) $this->_db->loadResult();
if (!$com_asset) {
continue;
}
// Search project asset
$query->clear();
$query->select('id')->from('#__assets')->where('parent_id = ' . $com_asset)->where('name = ' . $this->_db->quote($name . '.project.' . $pk))->order('id ASC');
$this->_db->setQuery($query, 0, 1);
$project_asset = (int) $this->_db->loadResult();
if ($project_asset) {
// Update asset
$asset = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
$asset->loadByName($name . '.project.' . $pk);
if (isset($this->asset_rules[$name])) {
if ($this->asset_rules[$name] instanceof JAccessRules) {
$asset->rules = (string) $this->asset_rules[$name];
} else {
$asset->rules = '{}';
}
} else {
$asset->rules = '{}';
}
if (!$asset->check() || !$asset->store(false)) {
$this->setError($asset->getError());
return false;
}
} else {
// Create asset
$asset = self::getInstance('Asset', 'JTable', array('dbo' => $this->getDbo()));
$asset->setLocation($com_asset, 'last-child');
$asset->parent_id = $com_asset;
$asset->name = $name . '.project.' . $pk;
$asset->title = empty($this->title) ? $asset->name : $this->title;
if (isset($this->asset_rules[$name])) {
if ($this->asset_rules[$name] instanceof JAccessRules) {
$asset->rules = (string) $this->asset_rules[$name];
}
}
if (!$asset->check() || !$asset->store(false)) {
$this->setError($asset->getError());
return false;
}
}
}
return true;
}