$task = 'list_sites';
            break;
    }
    $mainframe->redirect('index.php?option=com_community_acl&task=' . $task);
}
function deleteItem($table, $cid)
{
    global $mainframe;
    // Check for request forgeries
    JRequest::checkToken() or die('Invalid Token');
    // Initialize variables
    $db =& JFactory::getDBO();
    JArrayHelper::toInteger($cid);
    if (count($cid) < 1) {
        JError::raiseError(500, JText::_('Select a item to delete', true));
    }
    if (count($cid)) {
        $cids = implode(',', $cid);
        $query = 'DELETE FROM `' . $table . '`' . ' WHERE `id` IN ( ' . $cids . ' )';
        $db->setQuery($query);
        if (!$db->query()) {
            JError::raiseError(500, $db->stderr());
            return false;
        }
        switch ($table) {
            case '#__community_acl_groups':
                $query = 'SELECT `id` FROM `#__community_acl_roles`' . ' WHERE `group_id` IN ( ' . $cids . ' )';
                $db->setQuery($query);
                $rid = $db->loadResultArray();
                $query = 'DELETE FROM `#__community_acl_roles`' . ' WHERE `group_id` IN ( ' . $cids . ' )';
                $db->setQuery($query);
                if (!$db->query()) {
                    JError::raiseError(500, $db->stderr());
                    return false;
                }
                $query = 'DELETE FROM `#__community_acl_access`' . ' WHERE `group_id` IN ( ' . $cids . ' ) ' . (count($rid) > 0 ? ' OR `role_id` IN ( ' . implode(',', $rid) . ' )' : '');
                $db->setQuery($query);
                if (!$db->query()) {
                    JError::raiseError(500, $db->stderr());
                    return false;
                }
                $query = 'DELETE FROM `#__community_acl_users`' . ' WHERE `group_id` IN ( ' . $cids . ' ) ' . (count($rid) > 0 ? ' OR `role_id` IN ( ' . implode(',', $rid) . ' )' : '');
                $db->setQuery($query);
                if (!$db->query()) {
                    JError::raiseError(500, $db->stderr());
                    return false;
                }
                $query = "SELECT `id` FROM  `#__community_acl_sites` WHERE `is_main` = '1'";
                $db->setQuery($query);
                $sid = (int) $db->loadResult();
                if ($sid > 0) {
                    $main = new CACL_site($db);
                    $main->load($sid);
                    $config = new CACL_config($main->_site_db);
                    $config->load();
                    if ($config->synchronize && $config->cacl_grf) {
                        $sync = new CACL_syncronize($main);
                        foreach ($cid as $tid) {
                            $sync->syncronize($tid, 'cacl_group_delete');
                        }
                    }
                }
                break;
            case '#__community_acl_roles':
                $query = 'DELETE FROM `#__community_acl_access`' . ' WHERE `role_id` IN ( ' . $cids . ' ) ';
                $db->setQuery($query);
                if (!$db->query()) {
                    JError::raiseError(500, $db->stderr());
                    return false;
                }
                $query = 'DELETE FROM `#__community_acl_users`' . ' WHERE `role_id` IN ( ' . $cids . ' ) ';
                $db->setQuery($query);
                if (!$db->query()) {
                    JError::raiseError(500, $db->stderr());
                    return false;
                }
                $query = "SELECT `id` FROM  `#__community_acl_sites` WHERE `is_main` = '1'";
                $db->setQuery($query);
                $sid = (int) $db->loadResult();
                if ($sid > 0) {
                    $main = new CACL_site($db);
                    $main->load($sid);
                    $config = new CACL_config($main->_site_db);
                    $config->load();
                    if ($config->synchronize && $config->cacl_grf) {
                        $sync = new CACL_syncronize($main);
                        foreach ($cid as $tid) {
                            $sync->syncronize($tid, 'cacl_role_delete');
                        }
                    }
                }
                break;
            case '#__community_acl_functions':
                $query = 'DELETE FROM `#__community_acl_function_access`' . ' WHERE `func_id` IN ( ' . $cids . ' ) ';
                $db->setQuery($query);
                if (!$db->query()) {
                    JError::raiseError(500, $db->stderr());
                    return false;
                }
                $query = 'DELETE FROM `#__community_acl_users`' . ' WHERE `function_id` IN ( ' . $cids . ' ) ';
                $db->setQuery($query);
                if (!$db->query()) {
                    JError::raiseError(500, $db->stderr());
                    return false;
                }
                $query = "SELECT `id` FROM  `#__community_acl_sites` WHERE `is_main` = '1'";
                $db->setQuery($query);
                $sid = (int) $db->loadResult();
                if ($sid > 0) {
                    $main = new CACL_site($db);
                    $main->load($sid);
                    $config = new CACL_config($main->_site_db);
                    $config->load();
                    if ($config->synchronize && $config->cacl_grf) {
                        $sync = new CACL_syncronize($main);
                        foreach ($cid as $tid) {
                            $sync->syncronize($tid, 'cacl_func_delete');
                        }
                    }
                }
                break;
            case '#__community_acl_sites':
                $task = 'list_sites';
                break;
        }
    }
    $task = '';
    switch ($table) {
        case '#__community_acl_groups':
            $task = 'list_groups';
            break;
        case '#__community_acl_roles':
            $task = 'list_roles';
            break;
        case '#__community_acl_functions':
            $task = 'list_functions';
            break;
        case '#__community_acl_sites':
Ejemplo n.º 2
0
 function _syncCBContact()
 {
     require_once JPATH_SITE . '/administrator/components/com_community_acl/community_acl.class.php';
     $db =& JFactory::getDBO();
     $query = "SELECT `id` FROM  `#__community_acl_sites` WHERE `is_main` = '1'";
     $db->setQuery($query);
     $sid = (int) $db->loadResult();
     $main = new CACL_site($db);
     $main->load($sid);
     $config = new CACL_config($main->_site_db);
     $config->load();
     if (!$config->synchronize || !$config->cb_contact) {
         return;
     }
     $sync = new CACL_syncronize($main);
     $sync->syncronize(0, 'cb_contact');
 }
Ejemplo n.º 3
0
 /**
  * Disables the user account
  */
 function block()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     $db =& JFactory::getDBO();
     $acl =& JFactory::getACL();
     $currentUser =& JFactory::getUser();
     $cid = JRequest::getVar('cid', array(), '', 'array');
     $block = $this->getTask() == 'block' ? 1 : 0;
     JArrayHelper::toInteger($cid);
     if (count($cid) < 1) {
         JError::raiseError(500, JText::_('Select a User to ' . $this->getTask(), true));
     }
     foreach ($cid as $id) {
         // check for a super admin ... can't delete them
         $objectID = $acl->get_object_id('users', $id, 'ARO');
         $groups = $acl->get_object_groups($objectID, 'ARO');
         $this_group = strtolower($acl->get_group_name($groups[0], 'ARO'));
         $success = false;
         if ($this_group == 'super administrator') {
             $msg = JText::_('You cannot block a Super Administrator');
         } else {
             if ($id == $currentUser->get('id')) {
                 $msg = JText::_('You cannot block Yourself!');
             } else {
                 if ($this_group == 'administrator' && $currentUser->get('gid') == 24) {
                     $msg = JText::_('WARNBLOCK');
                 } else {
                     $user =& JUser::getInstance((int) $id);
                     $count = 2;
                     if ($user->get('gid') == 25) {
                         // count number of active super admins
                         $query = 'SELECT COUNT( id )' . ' FROM #__users' . ' WHERE gid = 25' . ' AND block = 0';
                         $db->setQuery($query);
                         $count = $db->loadResult();
                     }
                     if ($count <= 1 && $user->get('gid') == 25) {
                         // cannot delete Super Admin where it is the only one that exists
                         $msg = "You cannot block this Super Administrator as it is the only active Super Administrator for your site";
                     } else {
                         $user =& JUser::getInstance((int) $id);
                         $user->block = $block;
                         $user->save();
                         if ($block) {
                             JRequest::setVar('task', 'block');
                             JRequest::setVar('cid', array($id));
                             $query = "SELECT `id` FROM  `#__community_acl_sites` WHERE `is_main` = '1'";
                             $db->setQuery($query);
                             $sid = (int) $db->loadResult();
                             if ($sid > 0) {
                                 $main = new CACL_site($db);
                                 $main->load($sid);
                                 $config = new CACL_config($main->_site_db);
                                 $config->load();
                                 if ($config->synchronize && $config->users_and_cb) {
                                     $sync = new CACL_syncronize($main);
                                     $sync->syncronize($user->get('id'), 'user');
                                 }
                             }
                             // delete user acounts active sessions
                             $this->logout();
                         }
                     }
                 }
             }
         }
     }
     $this->setRedirect('index.php?option=com_community_acl&mode=manage_users', $msg);
 }