Example #1
0
/**
 * Deprecated since 1.8
 * Use CLimitsHelper::exceededGroupCreation instead.
 */
function cExceededGroupCreationLimit($userId)
{
    return CLimitsHelper::exceededGroupCreation($userId);
}
Example #2
0
 public static function groupsAdd($userId)
 {
     $config = CFactory::getConfig();
     $my = CFactory::getUser();
     if ($userId == 0) {
         CAccess::setError('blockUnregister');
         return false;
     } else {
         if (!$config->get('enablegroups')) {
             CACCESS::setError(JText::_('COM_COMMUNITY_GROUPS_DISABLE'));
             return false;
         } else {
             if (!$config->get('creategroups') || !(COwnerHelper::isCommunityAdmin() || COwnerHelper::isRegisteredUser() && $my->canCreateGroups())) {
                 CACCESS::setError(JText::_('COM_COMMUNITY_GROUPS_DISABLE_CREATE_MESSAGE'));
                 return false;
             } else {
                 if (CLimitsHelper::exceededGroupCreation($userId)) {
                     $groupLimit = $config->get('groupcreatelimit');
                     CACCESS::setError(JText::sprintf('COM_COMMUNITY_GROUPS_LIMIT', $groupLimit));
                     return false;
                 } else {
                     return true;
                 }
             }
         }
     }
 }
Example #3
0
 /**
  * Method to display the create group form
  **/
 public function create()
 {
     $my = CFactory::getUser();
     if ($my->id == 0) {
         return $this->blockUnregister();
     }
     $config = CFactory::getConfig();
     if (!$config->get('enablegroups')) {
         echo JText::_('CC GROUPS DISABLED');
         return;
     }
     CFactory::load('helpers', 'owner');
     if ($config->get('creategroups') && (COwnerHelper::isCommunityAdmin() || COwnerHelper::isRegisteredUser() && $my->canCreateGroups())) {
         CFactory::load('helpers', 'limits');
         if (CLimitsHelper::exceededGroupCreation($my->id)) {
             $groupLimit = $config->get('groupcreatelimit');
             echo JText::sprintf('CC GROUPS CREATION REACH LIMIT', $groupLimit);
             return;
         }
         $document =& JFactory::getDocument();
         $viewType = $document->getType();
         $viewName = JRequest::getCmd('view', $this->getName());
         $view =& $this->getView($viewName, '', $viewType);
         $model =& $this->getModel('groups');
         $data = new stdClass();
         $data->categories = $model->getCategories();
         if (JRequest::getVar('action', '', 'POST') == 'save') {
             CFactory::load('libraries', 'apps');
             $appsLib =& CAppPlugins::getInstance();
             $saveSuccess = $appsLib->triggerEvent('onFormSave', array('jsform-groups-forms'));
             if (empty($saveSuccess) || !in_array(false, $saveSuccess)) {
                 $gid = $this->save();
                 if ($gid !== FALSE) {
                     $mainframe =& JFactory::getApplication();
                     $group =& JTable::getInstance('Group', 'CTable');
                     $group->load($gid);
                     //trigger for onGroupCreate
                     $this->triggerGroupEvents('onGroupCreate', $group);
                     $url = CRoute::_('index.php?option=com_community&view=groups&task=created&groupid=' . $gid, false);
                     $mainframe->redirect($url, JText::sprintf('CC GROUP CREATED NOTICE', $group->name));
                     return;
                 }
             }
         }
     } else {
         echo JText::_('CC GROUPS CREATION DISABLED');
         return;
     }
     echo $view->get(__FUNCTION__, $data);
 }