当前位置: 首页>>代码示例>>PHP>>正文


PHP ShopFunctions::can方法代码示例

本文整理汇总了PHP中ShopFunctions::can方法的典型用法代码示例。如果您正苦于以下问题:PHP ShopFunctions::can方法的具体用法?PHP ShopFunctions::can怎么用?PHP ShopFunctions::can使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ShopFunctions的用法示例。


在下文中一共展示了ShopFunctions::can方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: can

 function can($task, $view, $created_by = null, $vendorId = null)
 {
     static $user_id = null;
     static $isAdmin = null;
     static $vendor = null;
     if ($vendor === null) {
         JLoader::register('Permissions', JPATH_VM_ADMINISTRATOR . '/helpers/permissions.php');
         $vendor = Permissions::getInstance()->isSuperVendor();
         if ($user_id = JFactory::getUser()->get('id')) {
             $isAdmin = Permissions::getInstance()->check("admin,storeadmin");
             JLoader::register('ShopFunctions', JPATH_VM_ADMINISTRATOR . '/helpers/shopfunctions.php');
         }
     }
     if (!$vendor) {
         return '';
     }
     if ($vendor > 1) {
         if (!ShopFunctions::can($task, $view)) {
             return false;
         }
         // only link to own entries or same vendor id
         if ($vendorId) {
             if ($vendorId != $vendor) {
                 return false;
             }
         } elseif ($created_by != $user_id) {
             return false;
         }
     }
     return true;
 }
开发者ID:denis1001,项目名称:Virtuemart-2-Joomla-3-Bootstrap,代码行数:31,代码来源:vmview.php

示例2: addStandardEditViewCommands

    function addStandardEditViewCommands($id = 0, $save2new = true)
    {
        // if (JRequest::getCmd('tmpl') =='component' ) {
        // if (!class_exists('JToolBarHelper')) require(JPATH_ADMINISTRATOR.DS.'includes'.DS.'toolbarhelper.php');
        // } else {
        // 		JRequest::setVar('hidemainmenu', true);
        $view = $this->getName();
        JToolBarHelper::divider();
        if (ShopFunctions::can('add', $view)) {
            if ($id) {
                JToolBarHelper::save2copy('save2copy', 'JTOOLBAR_SAVE_AS_COPY');
            }
            if ($save2new) {
                JToolbarHelper::save2new('save2new', 'JTOOLBAR_SAVE_AND_NEW');
            }
        }
        JToolBarHelper::save();
        JToolBarHelper::apply();
        JToolBarHelper::cancel();
        // todo add filter by view
        if ($id) {
            JToolBarHelper::custom('preview', 'eye', null, 'COM_VIRTUEMART_PREVIEW', false);
        }
        // }
        // javascript for cookies setting in case of press "APPLY"
        $document = JFactory::getDocument();
        if ($view == 'product') {
            $view = 'productdetails';
        }
        $j = "\n\t\t\tJoomla.submitbutton=function(a){\n\t\t\t\tvar options = { path: '/', expires: 2},\n\t\t\t\t\tlink = '';\n\t\t\t\tif (a == 'preview') {\n\t\t\t\t\tlink='" . juri::root() . "index.php?option=com_virtuemart&view=" . $view . "&" . $this->_cidName . "=" . $id . "';\n\t\t\t\t\twindow.location = link;\n\t\t\t\t\t// console.log(link);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (a == 'apply') {\n\t\t\t\t\tjQuery('#searchMedia-div ul').remove();\n\t\t\t\t\tvar idx = jQuery('#adminForm ul li.active').index();\n\t\t\t\t\tjQuery.cookie('vmapply', idx, options);\n\t\t\t\t} else {\n\t\t\t\t\tjQuery.cookie('vmapply', '0', options);\n\t\t\t\t}\n\t\t\t\tjQuery( '#media-dialog' ).remove();\n\t\t\t\tJoomla.submitform(a);\n\t\t\t};\n\t\t";
        $document->addScriptDeclaration($j);
        // LANGUAGE setting
        $editView = JRequest::getWord('view', '');
        $params = JComponentHelper::getParams('com_languages');
        //$config =JFactory::getConfig();$config->get('language');
        $selectedLangue = $params->get('site', 'en-GB');
        $lang = JFactory::getLanguage();
        if ($this->frontEdit) {
            $selectedLangue = $lang->getTag();
        }
        $lang = strtolower(strtr($selectedLangue, '-', '_'));
        // only add if ID and view not null
        if ($id && count(vmconfig::get('active_languages')) > 1) {
            if ($view == 'user') {
                $view = 'vendor';
            }
            //$params = JComponentHelper::getParams('com_languages');
            jimport('joomla.language.helper');
            $this->lang = JRequest::getVar('vmlang', $lang);
            $languages = JLanguageHelper::createLanguageList($selectedLangue, constant('JPATH_SITE'), true);
            $activeVmLangs = vmconfig::get('active_languages');
            foreach ($languages as $k => &$joomlaLang) {
                if (!in_array($joomlaLang['value'], $activeVmLangs)) {
                    unset($languages[$k]);
                }
            }
            $this->langList = JHTML::_('select.genericlist', $languages, 'vmlang', 'class="inputbox"', 'value', 'text', $selectedLangue, 'vmlang');
            $token = JSession::getFormToken();
            $j = '
			jQuery(function($) {
				var oldflag = "";
				$("select#vmlang").chosen().change(function() {
					langCode = $(this).val();
					flagClass = "flag-"+langCode.substr(0,2) ;
					$.getJSON( "index.php?option=com_virtuemart&view=translate&task=paste&format=json&lg="+langCode+"&id=' . $id . '&editView=' . $editView . '&' . $token . '=1' . $this->tmpl . '" ,
						function(data) {
							var items = [];

							if (data.fields !== "error" ) {
								if (data.structure == "empty") alert(data.msg);
								$.each(data.fields , function(key, val) {
									cible = jQuery("#"+key);
									if (oldflag !== "") cible.parent().removeClass(oldflag)
									if (cible.parent().addClass(flagClass).children().hasClass("mce_editable") && data.structure !== "empty" ) {
										if (tinyMCE.execInstanceCommand) tinyMCE.execInstanceCommand(key,"mceSetContent",false,val);
										else tinymce.editors[key].setContent(val);
									}
									else if (data.structure !== "empty") cible.val(val);
									});
								oldflag = flagClass ;
							} else alert(data.msg);
						}
					)
				});
			})';
            $document->addScriptDeclaration($j);
        } else {
            // $params = JComponentHelper::getParams('com_languages');
            // $lang = $params->get('site', 'en-GB');
            $jlang = JFactory::getLanguage();
            $langs = $jlang->getKnownLanguages();
            $defautName = $langs[$selectedLangue]['name'];
            $flagImg = JURI::root(true) . '/administrator/components/com_virtuemart/assets/images/flag/' . substr($lang, 0, 2) . '.png';
            $this->langList = '<input name ="vmlang" type="hidden" value="' . $selectedLangue . '" ><img style="vertical-align: middle;" alt="' . $defautName . '" src="' . $flagImg . '"> <b> ' . $defautName . '</b>';
            $this->lang = $lang;
        }
        //I absolutly do not understand for that should be for, note by Max
        /*		if ($object) {
        		   if(Vmconfig::get('multix','none')!=='none'){
        				$this->loadHelper('permissions');
//.........这里部分代码省略.........
开发者ID:denis1001,项目名称:Virtuemart-2-Joomla-3-Bootstrap,代码行数:101,代码来源:vmview.php

示例3: foreach

    echo $mainIcons[$topname];
    ?>
"></i><span class="desktop"><?php 
    echo jtext::_($topname);
    ?>
</span><span class="caret"></span></a>
								<ul class="dropdown-menu">
									<?php 
    foreach ($menus as $link => $name) {
        if ($task === 'add') {
            $viewArray = explode('&', $link);
            $view = $viewArray[0];
        } else {
            $view = $link;
        }
        if (!ShopFunctions::can($task, $view)) {
            continue;
        }
        $hasLink = true;
        ?>
										<li>
											<a href="<?php 
        echo jRoute::_('index.php?option=com_virtuemart&tmpl=component&view=' . $link);
        ?>
" class="menu-cpanel"><?php 
        echo jText::_($name);
        ?>
</a>
										</li>
									<?php 
    }
开发者ID:denis1001,项目名称:Virtuemart-2-Joomla-3-Bootstrap,代码行数:31,代码来源:edit.html.php

示例4: foreach

			 </th>
		<th width="40px"  class="hidden-phone"><?php 
echo $this->sort('published');
?>
</th>
		<th class="hidden-phone"><?php 
echo $this->sort('p.virtuemart_product_id', 'COM_VIRTUEMART_ID');
?>
</th>
	  </tr>
	</thead>
	<tbody>
	<?php 
if ($total = count($this->productlist)) {
    $i = 0;
    $canPublish = ShopFunctions::can('publish');
    foreach ($this->productlist as $key => $product) {
        $checked = JHTML::_('grid.id', $i, $product->virtuemart_product_id);
        $canDo = $this->canChange($product->created_by);
        $published = $this->toggle($product->published, $i, 'published', $canDo && $canPublish);
        // featured bootstrap style , canDo is the permission
        $is_featured = vmHtml::featured($product->product_special, $i, $canDo);
        ?>
			<tr sortable-group-id="<?php 
        echo $this->virtuemart_category_id;
        ?>
">
				<?php 
        if ($this->virtuemart_category_id) {
            ?>
					<td class="order nowrap center hidden-phone">
开发者ID:denis1001,项目名称:Virtuemart-2-Joomla-3-Bootstrap,代码行数:31,代码来源:default_results.php

示例5: display

 /**
  * Collect all data to show on the template
  *
  * @author RolandD, Max Milbers
  */
 function display($tpl = null)
 {
     //TODO get plugins running
     //		$dispatcher	= JDispatcher::getInstance();
     //		$limitstart	= JRequest::getVar('limitstart', 0, '', 'int');
     $this->show_prices = VmConfig::get('show_prices', 1);
     if ($this->show_prices == 1) {
         JLoader::register('calculationHelper', JPATH_VM_ADMINISTRATOR . '/helpers/calculationh.php');
     }
     $document = JFactory::getDocument();
     // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
     vmJsApi::jPrice();
     $app = JFactory::getApplication();
     $pathway = $app->getPathway();
     $task = JRequest::getCmd('task');
     JLoader::register('VmImage', JPATH_VM_ADMINISTRATOR . '/helpers/image.php');
     // Load the product
     //$product = $this->get('product');	//Why it is sensefull to use this construction? Imho it makes it just harder
     $this->product_model = VmModel::getModel('product');
     $virtuemart_product_idArray = JRequest::getVar('virtuemart_product_id', 0);
     if (is_array($virtuemart_product_idArray) and count($virtuemart_product_idArray) > 0) {
         $virtuemart_product_id = (int) $virtuemart_product_idArray[0];
     } else {
         $virtuemart_product_id = (int) $virtuemart_product_idArray;
     }
     $quantityArray = JRequest::getVar('quantity', array());
     //is sanitized then
     JArrayHelper::toInteger($quantityArray);
     $quantity = 1;
     if (!empty($quantityArray[0])) {
         $quantity = $quantityArray[0];
     }
     $onlyPublished = true;
     // set unpublished product when it's editable by its owner for preview
     if ($canEdit = ShopFunctions::can('edit', 'product')) {
         $onlyPublished = false;
     }
     $product = $this->product_model->getProduct($virtuemart_product_id, TRUE, TRUE, $onlyPublished, $quantity);
     if ($product && $canEdit) {
         JLoader::register('Permissions', JPATH_VM_ADMINISTRATOR . '/helpers/permissions.php');
         $vendor = Permissions::getInstance()->isSuperVendor();
         if ($vendor > 1 && $product->virtuemart_vendor_id !== $vendor) {
             $product = null;
         } elseif (!$product->published) {
             $app->enqueueMessage(JText::_('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_STATUS') . ' : ' . JText::_('COM_VIRTUEMART_UNPUBLISHED'), 'warning');
         }
     }
     $last_category_id = shopFunctionsF::getLastVisitedCategoryId();
     if (empty($product->slug)) {
         //Todo this should be redesigned to fit better for SEO
         $app->enqueueMessage(JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND'));
         $categoryLink = '';
         if (!$last_category_id) {
             $last_category_id = JRequest::getInt('virtuemart_category_id', false);
         }
         if ($last_category_id) {
             $categoryLink = '&virtuemart_category_id=' . $last_category_id;
         }
         if (VmConfig::get('handle_404', 1)) {
             $app->redirect(JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryLink . '&error=404', FALSE));
         } else {
             JError::raise(E_ERROR, '404', 'Not found');
         }
         return;
     }
     if (!empty($product->customfields)) {
         foreach ($product->customfields as $k => $custom) {
             if (!empty($custom->layout_pos)) {
                 $product->customfieldsSorted[$custom->layout_pos][] = $custom;
                 unset($product->customfields[$k]);
             }
         }
         $product->customfieldsSorted['normal'] = $product->customfields;
         unset($product->customfields);
     }
     $product->event = new stdClass();
     $product->event->afterDisplayTitle = '';
     $product->event->beforeDisplayContent = '';
     $product->event->afterDisplayContent = '';
     if (VmConfig::get('enable_content_plugin', 0)) {
         // add content plugin //
         $dispatcher =& JDispatcher::getInstance();
         JPluginHelper::importPlugin('content');
         $product->text = $product->product_desc;
         // jimport( 'joomla.html.parameter' );
         // $params = new JParameter('');
         $params = new JRegistry();
         $product->event = new stdClass();
         $results = $dispatcher->trigger('onContentPrepare', array('com_virtuemart.productdetails', &$product, &$params, 0));
         // More events for 3rd party content plugins
         // This do not disturb actual plugins, because we don't modify $product->text
         $res = $dispatcher->trigger('onContentAfterTitle', array('com_virtuemart.productdetails', &$product, &$params, 0));
         $product->event->afterDisplayTitle = trim(implode("\n", $res));
         $res = $dispatcher->trigger('onContentBeforeDisplay', array('com_virtuemart.productdetails', &$product, &$params, 0));
         $product->event->beforeDisplayContent = trim(implode("\n", $res));
//.........这里部分代码省略.........
开发者ID:denis1001,项目名称:Virtuemart-2-Joomla-3-Bootstrap,代码行数:101,代码来源:view.html.php

示例6: save

 /**
  * Generic save task
  *
  * @author Max Milbers
  * @param post $data sometimes we just want to override the data to process
  */
 function save($data = 0)
 {
     JSession::checkToken() or jexit('Invalid Token save');
     if ($data === 0) {
         $data = JRequest::get('post');
     }
     $task = JRequest::getCmd('task');
     // remove shared when not superVendor
     if ($this->_vendor > 1) {
         if (isset($data['shared'])) {
             $data['shared'] = 0;
         }
         if (!ShopFunctions::can('publish')) {
             $data['published'] = 0;
         }
         // check vendor max uploaded images
         if (!($max_uploads = ShopFunctions::can('max_uploads'))) {
             JRequest::setVar('uploads', null, 'files');
             jexit('save file error');
         }
         // better filter in mediaManager
         // else $medias = JRequest::getVar('uploads', array(), 'files');
     }
     // save2copy is same as save, only unset the primary ID
     if ($task == 'save2copy') {
         unset($data[$this->_cidName]);
         $data['published'] = 0;
     }
     $model = VmModel::getModel($this->_cname);
     $id = $model->store($data);
     $errors = $model->getErrors();
     if (empty($errors)) {
         $msg = JText::sprintf('COM_VIRTUEMART_STRING_SAVED', $this->mainLangKey);
         $type = 'message';
     } else {
         $type = 'error';
     }
     foreach ($errors as $error) {
         $msg = $error . '<br />';
     }
     $redir = $this->redirectPath;
     if ($task == 'apply' || $task == 'save2copy') {
         $redir .= '&task=edit&' . $this->_cidName . '=' . $id;
     } else {
         if ($task == 'save2new') {
             $redir .= '&task=add';
         }
     }
     if ($task == 'apply') {
         $app = JFactory::getApplication();
         $lastTab = $app->input->get('lastTab', '', 'cmd');
         $app->setUserState("com_virtuemart.lasttab", $lastTab);
     }
     //else $this->display();
     $this->setRedirect($redir, $msg, $type);
 }
开发者ID:denis1001,项目名称:Virtuemart-2-Joomla-3-Bootstrap,代码行数:62,代码来源:vmcontroller.php

示例7: _getAdminMenu

    /**
     * Build an array containing all the menu items.
     *
     * @param int $moduleId Id of the module to filter on
     */
    static function _getAdminMenu($moduleId = 0)
    {
        $db = JFactory::getDBO();
        $menuArr = array();
        $filter = array();
        $admin = JFactory::getUser()->authorise('core.admin');
        $manage = JFactory::getUser()->authorise('core.manage');
        $filter[] = "jmmod.published='1'";
        $filter[] = "item.published='1'";
        $filter[] = "jmmod.is_admin='1'";
        // simple vendor menu to display
        $isVendor = Permissions::getInstance()->isSuperVendor() > 1;
        if ($isVendor) {
            $or = array();
            $vendorViews = array("product", "category", "manufacturer", "media", "custom", "orders", "shoppers", "coupons", "report");
            foreach ($vendorViews as $view) {
                if (ShopFunctions::can('edit', $view)) {
                    $or[] = "item.view='" . $view . "'";
                }
            }
            $or[] = "item.view='virtuemart'";
            $or[] = "item.view='about'";
            $filter[] = '(' . implode(' OR ', $or) . ')';
        } elseif (!$admin) {
            // manager
            $filter[] = "item.view!='config'";
            $filter[] = "item.view!='updatesmigration'";
        }
        // var_dump($admin,$filter);
        // if (!$manage) {
        // $filter [] = "item.view!='config'";
        // }
        if (!empty($moduleId)) {
            $filter[] = 'vmmod.module_id=' . (int) $moduleId;
        }
        $query = 'SELECT `jmmod`.`module_id`, `module_name`, `module_perms`, `id`, `name`, `link`, `depends`, `icon_class`, `view`, `task`
						FROM `#__virtuemart_modules` AS jmmod
						LEFT JOIN `#__virtuemart_adminmenuentries` AS item ON `jmmod`.`module_id`=`item`.`module_id`
						WHERE  ' . implode(' AND ', $filter) . '
						ORDER BY `jmmod`.`ordering`, `item`.`ordering` ';
        $db->setQuery($query);
        $result = $db->loadAssocList();
        //		echo '<pre>'.print_r($query,1).'</pre>';
        for ($i = 0, $n = count($result); $i < $n; $i++) {
            $row = $result[$i];
            if ($linkComponent = strpos($row['link'], '?')) {
                $linkToSplit = explode('=', $row['link']);
                if ($linkToSplit[0] == 'index.php?option') {
                    $component = $linkToSplit[1];
                    VmConfig::loadJLang($component . '.sys');
                }
            }
            $menuArr[$row['module_id']]['title'] = 'COM_VIRTUEMART_' . strtoupper($row['module_name']) . '_MOD';
            $menuArr[$row['module_id']]['items'][] = $row;
        }
        return $menuArr;
    }
开发者ID:denis1001,项目名称:Virtuemart-2-Joomla-3-Bootstrap,代码行数:62,代码来源:adminui.php

示例8:

echo $this->DisplayFilterPublish();
?>
		<div class="btn-group pull-right"><?php 
echo $this->pagination->getLimitBox();
?>
</div>
		<div class="btn-group pull-left"><?php 
echo $this->lists['search_role'];
?>
</div>
	</div>
	<div class="clearfix"> </div>
	<div id="results">
		<?php 
// split to use ajax search
echo $this->loadTemplate('results');
?>
	</div>
	<?php 
if (ShopFunctions::can('removeAll')) {
    ?>
		<div class="btn-wrapper" id="toolbar-removeAll">
		<button onclick="Joomla.submitbutton('removeUnused')" class="btn btn-small">
		<span class="icon-delete"></span> remove all unused media and delete the files</button>
	<?php 
}
?>
</div>
</form>
<?php 
AdminUIHelper::endAdminArea(true);
开发者ID:denis1001,项目名称:Virtuemart-2-Joomla-3-Bootstrap,代码行数:31,代码来源:default.php

示例9:

    ?>
</strong></span>
			<a href="<?php 
    echo JROUTE::_('index.php?option=com_virtuemart&view=orders' . $this->tmpl);
    ?>
">
				<?php 
    echo JText::_('JALL');
    ?>
			</a>
		</div>
	</div>
</div>
<?php 
}
if (ShopFunctions::can('edit', 'orders')) {
    ?>
<div class="well well-small">
	<div class="module-title nav-header"><?php 
    echo JText::_('COM_VIRTUEMART_STATISTIC_NEW_CUSTOMERS');
    ?>
</div>
	<div class="row-striped">
		<?php 
    for ($i = 0, $n = count($this->recentCustomers); $i < $n; $i++) {
        $row = $this->recentCustomers[$i];
        $link = JROUTE::_('index.php?option=com_virtuemart&view=user&virtuemart_user_id=' . $row->virtuemart_user_id . $this->tmpl);
        ?>
			<div class="row-fluid">
	  			<a href="<?php 
        echo $link;
开发者ID:denis1001,项目名称:Virtuemart-2-Joomla-3-Bootstrap,代码行数:31,代码来源:default_statisticspage.php


注:本文中的ShopFunctions::can方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。