Example #1
0
 public function setDefaultPermissions(FileManager $tree)
 {
     $rootNode = $tree->getRootTreeNodeObject();
     $adminGroupEntity = GroupEntity::getOrCreate(Group::getByID(ADMIN_GROUP_ID));
     $pk = CategoryTreeNodeKey::getByHandle('view_category_tree_node');
     $pk->setPermissionObject($rootNode);
     $pa = Access::create($pk);
     $pa->addListItem($adminGroupEntity);
     $pt = $pk->getPermissionAssignmentObject();
     $pt->assignPermissionAccess($pa);
 }
Example #2
0
 public function load()
 {
     $db = Loader::db();
     $gID = $db->GetOne('select gID from PermissionAccessEntityGroups where peID = ?', array($this->peID));
     if ($gID) {
         $g = Group::getByID($gID);
         if (is_object($g)) {
             $this->group = $g;
             $this->label = $g->getGroupDisplayName();
         } else {
             $this->label = t('(Deleted Group)');
         }
     }
 }
Example #3
0
 public function getTreeNodeDisplayName($format = 'html')
 {
     if ($this->treeNodeParentID == 0) {
         return t('All Groups');
     }
     $g = UserGroup::getByID($this->gID);
     if (is_object($g)) {
         $gName = $g->getGroupDisplayName(false, false);
         switch ($format) {
             case 'html':
                 return h($gName);
             case 'text':
             default:
                 return $gName;
         }
     }
 }
 public static function add()
 {
     // copy permissions from the other node.
     $rootNode = ExpressEntryCategory::add();
     $treeID = parent::create($rootNode);
     $tree = self::getByID($treeID);
     $adminGroupEntity = GroupEntity::getOrCreate(ConcreteGroup::getByID(ADMIN_GROUP_ID));
     $permissions = ['view_express_entries', 'add_express_entries', 'edit_express_entries', 'delete_express_entries'];
     foreach ($permissions as $handle) {
         $pk = ExpressTreeNodeKey::getByHandle($handle);
         $pk->setPermissionObject($rootNode);
         $pa = Access::create($pk);
         $pa->addListItem($adminGroupEntity);
         $pt = $pk->getPermissionAssignmentObject();
         $pt->assignPermissionAccess($pa);
     }
     return $tree;
 }
Example #5
0
 public function testAddingBadgeToUser()
 {
     \Cache::disableAll();
     \Config::set('concrete.email.enabled', false);
     \Config::set('concrete.log.emails', false);
     Action::add('won_badge', t('Won a Badge'), 5, false);
     $g = Group::add('Test Group', 'Gettin a Badge');
     $g->setBadgeOptions(0, 'test', 10);
     $g = Group::getByID(1);
     $user = \Concrete\Core\User\UserInfo::add(array('uName' => 'testuser', 'uEmail' => '*****@*****.**'));
     $uo = $user->getUserObject();
     $uo->enterGroup($g);
     \Config::clear('concrete.email.enabled');
     \Config::clear('concrete.log.emails');
     $list = new EntryList();
     $list->filterbyUserName('testuser');
     $results = $list->get();
     $this->assertEquals(1, count($results));
     $result = $results[0];
     $this->assertInstanceOf('\\Concrete\\Core\\User\\Point\\Entry', $result);
     /* @var $result \Concrete\Core\User\Point\Entry */
     $this->assertInstanceOf('\\Concrete\\Core\\User\\Point\\Action\\WonBadgeAction', $result->getUserPointEntryActionObject());
     $this->assertInstanceOf('\\Concrete\\Core\\User\\Point\\Action\\WonBadgeActionDescription', $result->getUserPointEntryDescriptionObject());
 }
Example #6
0
 public function _getUserGroups($disableLogin = false)
 {
     $app = Application::getFacadeApplication();
     $req = Request::getInstance();
     $session = $app['session'];
     if ($session->has('uGroups') && !$disableLogin && !$req->hasCustomRequestUser()) {
         $ug = $session->get('uGroups');
     } else {
         $db = $app['database']->connection();
         if ($this->uID) {
             $ug[REGISTERED_GROUP_ID] = REGISTERED_GROUP_ID;
             $uID = $this->uID;
             $q = "select gID from UserGroups where uID = ?";
             $r = $db->query($q, array($uID));
             while ($row = $r->fetch()) {
                 $g = Group::getByID($row['gID']);
                 if ($g->isUserExpired($this)) {
                     $this->exitGroup($g);
                 } else {
                     $ug[$row['gID']] = $row['gID'];
                 }
             }
         }
         // now we populate also with guest information, since presumably logged-in users
         // see the same stuff as guest
         $ug[GUEST_GROUP_ID] = GUEST_GROUP_ID;
     }
     return $ug;
 }
Example #7
0
 /**
  * @param $queryRow
  *
  * @return \Concrete\Core\User\Group\Group
  */
 public function getResult($queryRow)
 {
     $g = Group::getByID($queryRow['gID']);
     return $g;
 }
 public function installMaintenanceModePermission()
 {
     $pk = Key::getByHandle('view_in_maintenance_mode');
     if (!$pk instanceof Key) {
         $pk = Key::add('admin', 'view_in_maintenance_mode', 'View Site in Maintenance Mode', 'Controls whether a user can access the website when its under maintenance.', false, false);
         $pa = $pk->getPermissionAccessObject();
         if (!is_object($pa)) {
             $pa = Access::create($pk);
         }
         $adminGroup = Group::getByID(ADMIN_GROUP_ID);
         if ($adminGroup) {
             $adminGroupEntity = GroupEntity::getOrCreate($adminGroup);
             $pa->addListItem($adminGroupEntity);
             $pt = $pk->getPermissionAssignmentObject();
             $pt->assignPermissionAccess($pa);
         }
     }
 }
Example #9
0
 /**
  * Filters by Group ID.
  */
 public function filterByGroupID($gID)
 {
     $group = Group::getByID($gID);
     $this->filterByGroup($group);
 }
Example #10
0
 public function getGroups()
 {
     $db = Loader::db();
     $r = $db->Execute('select gID from GroupSetGroups where gsID = ? order by gID asc', $this->getGroupSetId());
     $groups = array();
     while ($row = $r->FetchRow()) {
         $g = Group::getByID($row['gID']);
         if (is_object($g)) {
             $groups[] = $g;
         }
     }
     return $groups;
 }
Example #11
0
 public static function getBadges()
 {
     $gs = new GroupList();
     $gs->filter('gIsBadge', 1);
     $results = $gs->getResults();
     $badges = array();
     foreach ($results as $gr) {
         $badges[] = Group::getByID($gr['gID']);
     }
     return $badges;
 }
Example #12
0
 /** Creates a new user group.
  * @param string $gName
  * @param string $gDescription
  * @return Group
  */
 public static function add($gName, $gDescription, $parentGroup = false, $pkg = null, $gID = null)
 {
     $db = Loader::db();
     $pkgID = 0;
     if (is_object($pkg)) {
         $pkgID = $pkg->getPackageID();
     }
     $v = array($gID, $gName, $gDescription, $pkgID);
     $r = $db->prepare("insert into Groups (gID, gName, gDescription, pkgID) values (?, ?, ?, ?)");
     $res = $db->Execute($r, $v);
     if ($res) {
         $ng = Group::getByID($db->Insert_ID());
         // create a node for this group.
         if (is_object($parentGroup)) {
             $node = GroupTreeNode::getTreeNodeByGroupID($parentGroup->getGroupID());
         }
         if (!is_object($node)) {
             $tree = GroupTree::get();
             if (is_object($tree)) {
                 $node = $tree->getRootTreeNodeObject();
             }
         }
         if (is_object($node)) {
             GroupTreeNode::add($ng, $node);
         }
         $ge = new Event($ng);
         Events::dispatch('on_group_add', $ge);
         $ng->rescanGroupPath();
         return $ng;
     }
 }