Пример #1
0
 /**
  * Additional grid function for custom toggles
  *
  * @return string HTML code to write the toggle button
  */
 function toggle($field, $i, $toggle, $untoggleable = false, $imgY = 'tick.png', $imgX = 'publish_x.png', $prefix = '')
 {
     $img = $field ? $imgY : $imgX;
     if ($toggle == 'published') {
         // Stay compatible with grid.published
         $task = $field ? 'unpublish' : 'publish';
         $alt = $field ? JText::_('COM_VIRTUEMART_PUBLISHED') : JText::_('COM_VIRTUEMART_UNPUBLISHED');
         $action = $field ? JText::_('COM_VIRTUEMART_UNPUBLISH_ITEM') : JText::_('COM_VIRTUEMART_PUBLISH_ITEM');
     } else {
         $task = $field ? $toggle . '.0' : $toggle . '.1';
         $alt = $field ? JText::_('COM_VIRTUEMART_ENABLED') : JText::_('COM_VIRTUEMART_DISABLED');
         $action = $field ? JText::_('COM_VIRTUEMART_DISABLE_ITEM') : JText::_('COM_VIRTUEMART_ENABLE_ITEM');
     }
     if (VmConfig::isAtLeastVersion('1.6.0')) {
         $img = 'admin/' . $img;
     }
     $retImgSrc = JHTML::_('image.administrator', $img, '/images/', null, null, $alt);
     if ($untoggleable) {
         return $retImgSrc;
     } else {
         return '<a href="javascript:void(0);" onclick="return listItemTask(\'cb' . $i . '\',\'' . $task . '\')" title="' . $action . '">' . $retImgSrc . '</a>';
     }
 }
Пример #2
0
 /**
  * Return a list with groups that can be set by the current user
  *
  * @return mixed Array with groups that can be set, or the groupname (string) if it cannot be changed.
  */
 function getGroupList()
 {
     if (JVM_VERSION === 2) {
         //hm CB thing also not help
         // 			$_grpList = $this->get_groups_below_me();
         // 			return $_grpList;
         /*			if(!class_exists('UsersModelUser')) require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_users'.DS.'models'.DS.'user.php');
         			 $jUserModel = new UsersModelUser();
         			$list = $jUserModel->getGroups();
         
         			$user = JFactory::getUser();
         			if ($user->authorise('core.edit', 'com_users') && $user->authorise('core.manage', 'com_users'))
         			{
         			$model = JModel::getInstance('Groups', 'UsersModel', array('ignore_request' => true));
         			return $model->getItems();
         			}
         			else
         			{
         			return null;
         			}*/
         $user = JFactory::getUser();
         $authGroups = JAccess::getGroupsByUser($user->id);
         // 			$authGroups = $user->getAuthorisedGroups();
         // 			vmdebug('getGroupList j17',$authGroups);
         $db =& $this->getDbo();
         $where = implode($authGroups, '" OR `id` = "') . '"';
         $q = 'SELECT `id` as value,`title` as text FROM #__usergroups WHERE `id` = "' . $where;
         $db->setQuery($q);
         $list = $db->loadAssocList();
         // 			foreach($list as $item){
         // 				vmdebug('getGroupList $item ',$item);
         // 			}
         // 			vmdebug('getGroupList $q '.$list);
         return $list;
     } else {
         $_aclObject = JFactory::getACL();
         if (empty($this->_data)) {
             $this->getUser();
         }
         if (VmConfig::isAtLeastVersion('1.6.0')) {
             //TODO fix this latter. It's just an workarround to make it working on 1.6
             $gids = $this->_data->JUser->get('groups');
             return array_flip($gids);
         }
         $_usr = $_aclObject->get_object_id('users', $this->_data->JUser->get('id'), 'ARO');
         $_grp = $_aclObject->get_object_groups($_usr, 'ARO');
         $_grpName = strtolower($_aclObject->get_group_name($_grp[0], 'ARO'));
         $_currentUser = JFactory::getUser();
         $_my_usr = $_aclObject->get_object_id('users', $_currentUser->get('id'), 'ARO');
         $_my_grp = $_aclObject->get_object_groups($_my_usr, 'ARO');
         $_my_grpName = strtolower($_aclObject->get_group_name($_my_grp[0], 'ARO'));
         // administrators can't change each other and frontend-only users can only see groupnames
         if ($_grpName == $_my_grpName && $_my_grpName == 'administrator' || !$_aclObject->is_group_child_of($_my_grpName, 'Public Backend')) {
             return $_grpName;
         } else {
             $_grpList = $_aclObject->get_group_children_tree(null, 'USERS', false);
             $_remGroups = $_aclObject->get_group_children($_my_grp[0], 'ARO', 'RECURSE');
             if (!$_remGroups) {
                 $_remGroups = array();
             }
             // Make sure privs higher than my own can't be granted
             if (in_array($_grp[0], $_remGroups)) {
                 // nor can privs of users with higher privs be decreased.
                 return $_grpName;
             }
             $_i = 0;
             $_j = count($_grpList);
             while ($_i < $_j) {
                 if (in_array($_grpList[$_i]->value, $_remGroups)) {
                     array_splice($_grpList, $_i, 1);
                     $_j = count($_grpList);
                 } else {
                     $_i++;
                 }
             }
             return $_grpList;
         }
     }
 }
Пример #3
0
 /**
  * Additional grid function for custom toggles
  *
  * @return string HTML code to write the toggle button
  */
 function toggle($field, $i, $toggle, $imgY = 'tick.png', $imgX = 'publish_x.png', $prefix = '')
 {
     $img = $field ? $imgY : $imgX;
     if ($toggle == 'published') {
         // Stay compatible with grid.published
         $task = $field ? 'unpublish' : 'publish';
         $alt = $field ? JText::_('COM_VIRTUEMART_PUBLISHED') : JText::_('COM_VIRTUEMART_UNPUBLISHED');
         $action = $field ? JText::_('COM_VIRTUEMART_UNPUBLISH_ITEM') : JText::_('COM_VIRTUEMART_PUBLISH_ITEM');
     } else {
         $task = $field ? $toggle . '.0' : $toggle . '.1';
         $alt = $field ? JText::_('COM_VIRTUEMART_PUBLISHED') : JText::_('COM_VIRTUEMART_DISABLED');
         $action = $field ? JText::_('COM_VIRTUEMART_DISABLE_ITEM') : JText::_('COM_VIRTUEMART_ENABLE_ITEM');
     }
     if (VmConfig::isAtLeastVersion('1.6.0')) {
         return '<a href="javascript:void(0);" onclick="return listItemTask(\'cb' . $i . '\',\'' . $task . '\')" title="' . $action . '">' . JHTML::_('image', 'admin/' . $img, $alt, null, true) . '</a>';
     }
     return '<a href="javascript:void(0);" onclick="return listItemTask(\'cb' . $i . '\',\'' . $task . '\')" title="' . $action . '">' . '<img src="images/' . $img . '" border="0" alt="' . $alt . '" /></a>';
 }