Esempio n. 1
0
 /**
  *
  */
 function index()
 {
     $rep = $this->getResponse('html');
     $tpl = new jTpl();
     $gid = array(0);
     $o = new StdClass();
     $o->id_aclgrp = '0';
     $o->name = jLocale::get('jacl2_admin~acl2.anonymous.group.name');
     $o->grouptype = 0;
     $groups = array($o);
     $grouprights = array(0 => false);
     foreach (jAcl2DbUserGroup::getGroupList() as $grp) {
         $gid[] = $grp->id_aclgrp;
         $groups[] = $grp;
         $grouprights[$grp->id_aclgrp] = false;
     }
     $rights = array();
     $p = jAcl2Db::getProfil();
     $rs = jDao::get('jelix~jacl2subject', $p)->findAllSubject();
     foreach ($rs as $rec) {
         $rights[$rec->id_aclsbj] = $grouprights;
     }
     $rs = jDao::get('jelix~jacl2rights', $p)->getRightsByGroups($gid);
     foreach ($rs as $rec) {
         $rights[$rec->id_aclsbj][$rec->id_aclgrp] = true;
     }
     $tpl->assign(compact('groups', 'rights'));
     if (jAcl2::check('acl.group.modify')) {
         $rep->body->assign('MAIN', $tpl->fetch('groups_right'));
     } else {
         $rep->body->assign('MAIN', $tpl->fetch('groups_right_view'));
     }
     return $rep;
 }
 /**
  * set rights on the given forum
  * @param integer $group the group id.
  * @param array $rights list of rights key = subject, value = true
  * @param string $resource the resource corresponding to the "forum" string + id_forum
  */
 public static function setRightsOnForum($group, $rights, $resource)
 {
     $dao = jDao::get('jacl2db~jacl2rights', jAcl2Db::getProfile());
     $dao->deleteHfnuByGroup($group, $resource);
     foreach ($rights as $sbj => $val) {
         if ($val != '') {
             jAcl2DbManager::addRight($group, $sbj, $resource);
         }
     }
     jAcl2::clearCache();
 }
Esempio n. 3
0
 /**
  * function to manage data before assigning to the template of its zone
  */
 protected function _prepareTpl()
 {
     $page = (int) $this->param('page');
     $memberSearch = (string) $this->param('memberSearch');
     // get letter  in lowercase
     $letter = $this->param('letter');
     if ($letter < chr(97) or $letter > chr(123)) {
         $letter = '';
     }
     $grpid = -2;
     if ($this->param('grpid')) {
         $grpid = intval($this->param('grpid'));
     }
     $nbMembersPerPage = (int) jApp::config()->havefnubb['members_per_page'];
     $p = jAcl2Db::getProfile();
     // $memberSearch == '' means, we dont search some members by their nickname
     if ($grpid == -2) {
         //all users
         $dao = jDao::get('jacl2db~jacl2groupsofuser', $p);
         $cond = jDao::createConditions();
         $cond->addCondition('grouptype', '=', 2);
         $cond->addCondition('status', '=', 1);
         if (strlen($letter) == 1) {
             $cond->addCondition('login', 'like', $letter . '%');
         } elseif ($memberSearch != '') {
             $cond->addCondition('login', 'like', '%' . $memberSearch . '%');
         }
         $rs = $dao->findBy($cond, $page, $nbMembersPerPage);
         $nbMembers = $dao->countBy($cond);
     } else {
         //in a specific group
         $dao = jDao::get('jacl2db~jacl2usergroup', $p);
         if ($letter == '') {
             $rs = $dao->getPublicUsersGroupLimit($grpid, $page, $nbMembersPerPage);
         } else {
             $rs = $dao->getPublicUsersByLetterGroupLimit($grpid, $page, $nbMembersPerPage, $letter . '%');
         }
         $nbMembers = $dao->getUsersGroupCount($grpid);
     }
     $members = array();
     $dao2 = jDao::get('jacl2db~jacl2groupsofuser', $p);
     foreach ($rs as $u) {
         $u->groups = array();
         $gl = $dao2->getGroupsUser($u->login);
         foreach ($gl as $g) {
             if ($g->grouptype != 2 and $g->status == 1) {
                 $u->groups[] = $g;
             }
         }
         $members[] = $u;
     }
     $groups = array();
     $o = new StdClass();
     $o->id_aclgrp = '-2';
     $o->name = jLocale::get('havefnubb~member.memberlist.allgroups');
     $o->grouptype = 0;
     $groups[] = $o;
     foreach (jAcl2DbUserGroup::getGroupList() as $grp) {
         $groups[] = $grp;
     }
     $letters[] = jLocale::get('havefnubb~member.memberlist.select.an.initial.nickname');
     for ($i = 0; $i < 26; $i++) {
         $letters[] = chr(97 + $i);
     }
     $daoRank = jDao::get('havefnubb~ranks');
     $ranks = $daoRank->findAll();
     // let's build the pagelink var
     // A Preparing / Collecting datas
     // 0- the properties of the pager
     $properties = array('start-label' => '', 'prev-label' => '', 'next-label' => '', 'end-label' => jLocale::get("havefnubb~member.pagelinks.end"), 'area-size' => 5);
     // 1- vars for pagelinks
     $this->_tpl->assign('groups', $groups);
     $this->_tpl->assign('page', $page);
     $this->_tpl->assign('nbMembersPerPage', $nbMembersPerPage);
     $this->_tpl->assign('properties', $properties);
     $this->_tpl->assign('members', $members);
     $this->_tpl->assign('nbMembers', $nbMembers);
     $this->_tpl->assign('letters', $letters);
     $this->_tpl->assign('ranks', $ranks);
 }
Esempio n. 4
0
 /**
  * return a list of group.
  *
  * if a login is given, it returns only the groups of the user.
  * Else it returns all groups (except private groups)
  * @param string $login an optional login
  * @return array a list of groups object (dao records)
  */
 public static function getGroupList($login = '')
 {
     if ($login === '') {
         return jDao::get('jelix~jacl2group', jAcl2Db::getProfile())->findAllPublicGroup();
     } else {
         return jDao::get('jelix~jacl2groupsofuser', jAcl2Db::getProfile())->getGroupsUser($login);
     }
 }
 /**
  * Delete the given subject
  * @param string  $subject the key of the subject
  */
 public static function removeSubject($subject)
 {
     $p = jAcl2Db::getProfile();
     jDao::get('jelix~jacl2rights', $p)->deleteBySubject($subject);
     jDao::get('jelix~jacl2subject', $p)->delete($subject);
     jAcl2::clearCache();
 }
Esempio n. 6
0
 private function _getGrpId($param, $onlypublic = false)
 {
     if ($onlypublic) {
         $c = ' grouptype <2 AND ';
     } else {
         $c = '';
     }
     $cnx = jDb::getConnection(jAcl2Db::getProfile());
     $sql = "SELECT id_aclgrp FROM " . $cnx->prefixTable('jacl2_group') . " WHERE {$c} ";
     if (is_numeric($param)) {
         if ($param == '0') {
             return 0;
         }
         $sql .= " id_aclgrp = " . $param;
     } else {
         if ($param == 'anonymous') {
             return 0;
         }
         $sql .= " name = " . $cnx->quote($param);
     }
     $rs = $cnx->query($sql);
     if ($rec = $rs->fetch()) {
         return $rec->id_aclgrp;
     } else {
         throw new Exception("this group doesn't exist or is private");
     }
 }
Esempio n. 7
0
 protected function getAnonymousRight($subject, $resource = null)
 {
     if (self::$anonacl === null) {
         $dao = jDao::get('jelix~jacl2rights', jAcl2Db::getProfile());
         self::$anonacl = array();
         foreach ($dao->getAllAnonymousRights() as $rec) {
             self::$anonacl[$rec->id_aclsbj] = true;
         }
     }
     if (!isset(self::$anonacl[$subject])) {
         self::$anonacl[$subject] = false;
     }
     if ($resource === null) {
         return self::$anonacl[$subject];
     }
     if (isset(self::$anonaclres[$subject][$resource])) {
         return self::$anonaclres[$subject][$resource];
     }
     self::$anonaclres[$subject][$resource] = self::$anonacl[$subject];
     if (!self::$anonacl[$subject]) {
         $dao = jDao::get('jelix~jacl2rights', jAcl2Db::getProfile());
         $right = $dao->getAnonymousRightWithRes($subject, $resource);
         self::$anonaclres[$subject][$resource] = $r = $right != false;
         return $r;
     } else {
         return true;
     }
 }
Esempio n. 8
0
 function saverightres()
 {
     $rep = $this->getResponse('redirect');
     $login = $this->param('user');
     $subjects = $this->param('subjects', array());
     if ($login == '') {
         $rep->action = 'jacl2db_admin~users:index';
         return $rep;
     }
     $rep->action = 'jacl2db_admin~users:rightres';
     $rep->params = array('user' => $login);
     $daogroup = jDao::get('jelix~jacl2group', jAcl2Db::getProfile());
     $grp = $daogroup->getPrivateGroup($login);
     $subjectsToRemove = array();
     foreach ($subjects as $sbj => $val) {
         if ($val != '' || $val == true) {
             $subjectsToRemove[] = $sbj;
         }
     }
     jDao::get('jelix~jacl2rights', jAcl2Db::getProfile())->deleteRightsOnResource($grp->id_aclgrp, $subjectsToRemove);
     jMessage::add(jLocale::get('acl2.message.user.rights.ok'), 'ok');
     return $rep;
 }
Esempio n. 9
0
 function edit()
 {
     $id_forum = (int) $this->param('id_forum');
     if ($id_forum == 0) {
         jMessage::add(jLocale::get('hfnuadmin~forum.invalid.datas'), 'error');
         $rep = $this->getResponse('redirect');
         $rep->action = 'hfnuadmin~forum:index';
         return $rep;
     }
     $dao = jDao::get('havefnubb~forum');
     $forum = $dao->get($id_forum);
     $form = jForms::create('hfnuadmin~forum_edit', $id_forum);
     $form->initFromDao("havefnubb~forum");
     $rep = $this->getResponse('html');
     $rep->body->assign('selectedMenuItem', 'forum');
     $tpl = new jTpl();
     $gid = array(0);
     $o = new StdClass();
     $o->id_aclgrp = '__anonymous';
     $o->name = jLocale::get('jacl2db_admin~acl2.anonymous.group.name');
     $o->grouptype = 0;
     $groups = array($o);
     $grouprights = array('__anonymous' => false);
     $dao = jDao::get('jacl2db~jacl2group', jAcl2Db::getProfile())->findAllPublicGroup();
     foreach ($dao as $grp) {
         $gid[] = $grp->id_aclgrp;
         $groups[] = $grp;
         $grouprights[$grp->id_aclgrp] = false;
     }
     $rights = array();
     $p = jAcl2Db::getProfile();
     $rs = jDao::get('jacl2db~jacl2subject', $p)->findHfnuSubject();
     foreach ($rs as $rec) {
         $rights[$rec->id_aclsbj] = $grouprights;
     }
     $rs = jDao::get('jacl2db~jacl2rights', $p)->getHfnuRightsByGroups($gid, 'forum' . $id_forum);
     foreach ($rs as $rec) {
         $rights[$rec->id_aclsbj][$rec->id_aclgrp] = true;
     }
     $tpl->assign('forum', $forum);
     $tpl->assign('form', $form);
     $tpl->assign(compact('groups', 'rights'));
     $rep->body->assign('MAIN', $tpl->fetch('forum_edit'));
     return $rep;
 }
Esempio n. 10
0
 function saverightres()
 {
     $rep = $this->getResponse('redirect');
     $rep->action = 'jacl2db_admin~groups:rightres';
     $subjects = $this->param('subjects', array());
     $groupid = $this->intParam('group', null);
     if ($groupid === null || $groupid < 0) {
         $rep->action = 'jacl2db_admin~groups:rights';
         return $rep;
     }
     $p = jAcl2Db::getProfile();
     $daogroup = jDao::get('jelix~jacl2group', $p);
     if ($groupid > 0) {
         $group = $daogroup->get($groupid);
         if (!$group) {
             $rep->action = 'jacl2db_admin~groups:rights';
             return $rep;
         }
     }
     $rep->params = array('group' => $groupid);
     $subjectsToRemove = array();
     foreach ($subjects as $sbj => $val) {
         if ($val != '' || $val == true) {
             $subjectsToRemove[] = $sbj;
         }
     }
     jDao::get('jelix~jacl2rights', jAcl2Db::getProfile())->deleteRightsOnResource($groupid, $subjectsToRemove);
     jMessage::add(jLocale::get('jacl2db_admin~acl2.message.group.rights.ok'), 'ok');
     return $rep;
 }
Esempio n. 11
0
 function saverights()
 {
     $rep = $this->getResponse('redirect');
     $login = $this->param('user');
     $rights = $this->param('rights', array());
     if ($login == '') {
         $rep->action = 'jacl2_admin~users:index';
         return $rep;
     }
     $rep->action = 'jacl2_admin~users:rights';
     $rep->params = array('user' => $login);
     $dao = jDao::get('jelix~jacl2groupsofuser', jAcl2Db::getProfil());
     $grp = $dao->getPrivateGroup($login);
     jAcl2DbManager::setRightsOnGroup($grp->id_aclgrp, $rights);
     return $rep;
 }
Esempio n. 12
0
 private function _getGrpId($param)
 {
     $cnx = jDb::getConnection(jAcl2Db::getProfile());
     $sql = "SELECT id_aclgrp FROM " . $cnx->prefixTable('jacl2_group') . " WHERE grouptype <2 ";
     if (is_numeric($param)) {
         if (intval($param) <= 0) {
             throw new Exception('invalid group id');
         }
         $sql .= " AND id_aclgrp = " . $param;
     } else {
         $sql .= " AND name = " . $cnx->quote($param);
     }
     $rs = $cnx->query($sql);
     if ($rec = $rs->fetch()) {
         return $rec->id_aclgrp;
     } else {
         throw new Exception("this group doesn't exist or is private");
     }
 }
Esempio n. 13
0
 function saveconfig()
 {
     $resp = $this->getResponse('redirect');
     $resp->action = 'hfnuadmin~default:config';
     $form = jForms::fill('hfnuadmin~config');
     if (!$form->check()) {
         return $resp;
     }
     $defaultConfig = new jIniFileModifier(jApp::configPath('defaultconfig.ini.php'));
     $p = jAcl2Db::getProfile();
     //if we want to allow the anonymous users on the forum :
     if ($form->getData('anonymous_post_authorized')) {
         $rights = array('hfnu.forum.list' => 'on', 'hfnu.forum.view' => 'on', 'hfnu.posts.list' => 'on', 'hfnu.posts.view' => 'on', 'hfnu.posts.rss' => 'on', 'hfnu.posts.reply' => 'on', 'hfnu.posts.create' => 'on', 'hfnu.search' => 'on');
         jAcl2DbManager::setRightsOnGroup('__anonymous', $rights);
     } else {
         jAcl2DbManager::setRightsOnGroup('__anonymous', array());
     }
     $defaultConfig->setValue('title', htmlentities($this->param('title')), 'havefnubb');
     $defaultConfig->setValue('description', htmlentities($form->getData('description')), 'havefnubb');
     $defaultConfig->setValue('webmasterEmail', $this->param('webmaster_email'), 'mailer');
     $defaultConfig->setValue('rules', str_replace('"', '', $form->getData('rules')), 'havefnubb');
     $defaultConfig->setValue('admin_email', $form->getData('admin_email'), 'havefnubb');
     $defaultConfig->setValue('posts_per_page', $form->getData('posts_per_page'), 'havefnubb');
     $defaultConfig->setValue('replies_per_page', $form->getData('replies_per_page'), 'havefnubb');
     $defaultConfig->setValue('members_per_page', $form->getData('members_per_page'), 'havefnubb');
     $defaultConfig->setValue('stats_nb_of_lastpost', $form->getData('stats_nb_of_lastpost'), 'havefnubb');
     $defaultConfig->setValue('post_max_size', $form->getData('post_max_size'), 'havefnubb');
     $defaultConfig->setValue('avatar_max_width', $form->getData('avatar_max_width'), 'havefnubb');
     $defaultConfig->setValue('avatar_max_height', $form->getData('avatar_max_height'), 'havefnubb');
     $defaultConfig->setValue('important_nb_replies', $form->getData('important_nb_replies'), 'havefnubb');
     $defaultConfig->setValue('important_nb_views', $form->getData('important_nb_views'), 'havefnubb');
     $defaultConfig->setValue('anonymous_post_authorized', $form->getData('anonymous_post_authorized'), 'havefnubb');
     $defaultConfig->setValue('twitter', $form->getData('social_network_twitter'), 'social_networks');
     $defaultConfig->setValue('digg', $form->getData('social_network_digg'), 'social_networks');
     $defaultConfig->setValue('delicious', $form->getData('social_network_delicious'), 'social_networks');
     $defaultConfig->setValue('facebook', $form->getData('social_network_facebook'), 'social_networks');
     $defaultConfig->setValue('reddit', $form->getData('social_network_reddit'), 'social_networks');
     $defaultConfig->setValue('netvibes', $form->getData('social_network_netvibes'), 'social_networks');
     $tz = DateTimeZone::listIdentifiers();
     $defaultConfig->setValue('timeZone', $tz[$form->getData('timezone')]);
     $defaultConfig->save();
     $floodConfig = new jIniFileModifier(jApp::configPath('havefnubb/flood.coord.ini.php'));
     $floodConfig->setValue('only_same_ip', $form->getData('only_same_ip'));
     $floodConfig->setValue('elapsed_time_between_two_post', $form->getData('elapsed_time_between_two_post'));
     $floodConfig->save();
     jForms::destroy('hfnuadmin~config');
     jMessage::add(jLocale::get('hfnuadmin~config.config.modified'), 'ok');
     return $resp;
 }