Exemple #1
0
 /**
  * return the value of the right on the given subject (and on the optional resource)
  * @param string $subject the key of the subject
  * @param string $resource the id of a resource
  * @return array list of values corresponding to the right
  */
 public function getRight($subject, $resource = null)
 {
     if ($resource === null && isset(self::$acl[$subject])) {
         return self::$acl[$subject];
     } elseif (isset(self::$aclres[$subject][$resource])) {
         return self::$aclres[$subject][$resource];
     }
     if (!jAuth::isConnected()) {
         // not authificated = no rights
         return array();
     }
     $groups = jAclDbUserGroup::getGroups();
     if (count($groups) == 0) {
         self::$acl[$subject] = array();
         self::$aclres[$subject][$resource] = array();
         return array();
     }
     // get all the values corresponding to the groups which the user has access to,
     //  with the subject and resource indicated
     $values = array();
     $dao = jDao::get('jacldb~jaclrights', 'jacl_profile');
     $list = $dao->getAllGroupRights($subject, $groups);
     foreach ($list as $right) {
         $values[] = $right->value;
     }
     self::$acl[$subject] = $values;
     if ($resource !== null) {
         $list = $dao->getAllGroupRightsWithRes($subject, $groups, $resource);
         foreach ($list as $right) {
             $values[] = $right->value;
         }
         self::$aclres[$subject][$resource] = $values = array_unique($values);
     }
     return $values;
 }
 /**
  * handle the search of specific member
  */
 function index()
 {
     $title = stripslashes(jApp::config()->havefnubb['title']);
     $rep = $this->getResponse('html');
     $letter = $this->param('letter');
     $id_rank = (int) $this->param('id_rank');
     $memberSearch = (string) $this->param('member_search');
     $page = 0;
     $page = (int) $this->param('page');
     // get the group name of the group id we request
     $grpid = $this->param('grpid');
     $groupname = jLocale::get('havefnubb~member.memberlist.allgroups');
     if ($grpid != '__anonymous') {
         $dao = jDao::get('jacl2db~jacl2group');
         $grpname = $dao->get($grpid);
         $groupname = $grpname->name;
     }
     $beginningBy = '';
     if (strlen($letter) == 1) {
         $beginningBy = ' - ' . jLocale::get('havefnubb~member.memberlist.members.beginning.by', array($letter));
     }
     // change the label of the breadcrumb
     if ($page == 0) {
         jApp::coord()->getPlugin('history')->change('label', jLocale::get('havefnubb~member.memberlist.members.list'));
         $rep->title = jLocale::get('havefnubb~member.memberlist.members.list') . ' - ' . $groupname . $beginningBy;
     } else {
         jApp::coord()->getPlugin('history')->change('label', jLocale::get('havefnubb~member.memberlist.members.list') . ' ' . ($page + 1));
         $rep->title = jLocale::get('havefnubb~member.memberlist.members.list') . ' - ' . $groupname . $beginningBy . ' ' . ($page + 1);
     }
     $rep->body->assignZone('MAIN', 'memberlist', array('page' => $page, 'grpid' => $grpid, 'letter' => $letter, 'memberSearch' => $memberSearch));
     return $rep;
 }
Exemple #3
0
 /**
  * return the value of the right on the given subject (and on the optional resource)
  * @param string $subject the key of the subject
  * @param string $resource the id of a resource
  * @return array list of values corresponding to the right
  */
 public function getRight($subject, $resource = null)
 {
     if ($resource === null && isset(self::$acl[$subject])) {
         return self::$acl[$subject];
     } elseif (isset(self::$aclres[$subject][$resource])) {
         return self::$aclres[$subject][$resource];
     }
     if (!jAuth::isConnected()) {
         // not authificated = no rights
         return array();
     }
     $groups = jAclDbUserGroup::getGroups();
     if (count($groups) == 0) {
         self::$acl[$subject] = array();
         self::$aclres[$subject][$resource] = array();
         return array();
     }
     // recupère toutes les valeurs correspondant aux groupes auquel appartient le user,
     //   avec le sujet et ressource indiqué
     $values = array();
     $dao = jDao::get('jelix~jaclrights', jAclDb::getProfile());
     $list = $dao->getAllGroupRights($subject, $groups);
     foreach ($list as $right) {
         $values[] = $right->value;
     }
     self::$acl[$subject] = $values;
     if ($resource !== null) {
         $list = $dao->getAllGroupRightsWithRes($subject, $groups, $resource);
         foreach ($list as $right) {
             $values[] = $right->value;
         }
         self::$aclres[$subject][$resource] = $values = array_unique($values);
     }
     return $values;
 }
 /**
  *
  */
 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;
 }
 /**
  * get the category from the given id
  * @param integer $id current category
  * @return $cat array
  */
 public static function getCat($id)
 {
     if (!isset(self::$cat[$id])) {
         self::$cat[$id] = jDao::get('havefnubb~forum_cat')->get($id);
     }
     return self::$cat[$id];
 }
 function savecreate()
 {
     $form = $this->_getForm();
     $form->initFromRequest();
     $rep = $this->getResponse('redirect');
     if ($form == null) {
         $rep->action = $this->_getAction('index');
         return $rep;
     }
     if ($form->check() && $this->_checkData($form, false)) {
         extract($form->prepareDaoFromControls($this->dao, null, $this->dbProfile), EXTR_PREFIX_ALL, "form");
         $dao = jDao::get('emails');
         if ($dao->get($form->getData('email')) == null) {
             $form_dao->insert($form_daorec);
             $id = $form_daorec->getPk();
             $form->saveAllFiles($this->uploadsDirectory);
             $rep->action = 'NewsLetter~emails:confirm';
             $this->_afterCreate($form, $id, $rep);
             jForms::destroy($this->form);
             $rep->params['id'] = $id;
             return $rep;
         } else {
             $rep->action = 'NewsLetter~emails:alreadyIn';
             return $rep;
         }
     } else {
         $rep->action = 'NewsLetter~emails:create';
         return $rep;
     }
 }
 /**
  * function to manage data before assigning to the template of its zone
  */
 protected function _prepareTpl()
 {
     $id = (int) $this->param('id');
     if ($id) {
         $this->_tpl->assign('user', jDao::get('havefnubb~member')->getById($id));
     }
 }
 /**
  * updating the search_words table for each of the following event
  */
 function onHfnuSearchEngineAddContent($event)
 {
     $id = $event->getParam('id');
     $ds = $event->getParam('datasource');
     $strId = '';
     if (is_array($id)) {
         for ($i = 0; $i < count($id); $i++) {
             $strId .= $id[$i];
         }
     } else {
         $strId = $id;
     }
     // 1) get the column definition we whish to index in the search engine
     $HfnuSearchConfig = parse_ini_file(jApp::configPath() . 'havefnu.search.ini.php', true);
     //getting the column name on which we need to make the query
     $indexSubject = $HfnuSearchConfig[$ds]['index_subject'];
     $indexMessage = $HfnuSearchConfig[$ds]['index_message'];
     // 2) get the Datas we just added
     $dao = jDao::get($ds);
     $rec = $dao->get($id);
     $subject = $indexSubject != '' ? $rec->{$indexSubject} : '';
     $message = $indexMessage != '' ? $rec->{$indexMessage} : '';
     // 3) get the service and initialize the needed properties
     jClasses::inc('hfnusearch~search_index');
     $service = new search_index($strId, $ds, $subject, $message);
     // update the SearchWords table !
     $service->searchEngineUpdate();
 }
Exemple #9
0
 /**
  * check if there is a flood
  * @param integer $timeInterval time between two actions
  * @param integer $onlySameIp  true: the flood is checked only between same ip
  * @return boolean  true if flood is detected
  */
 public static function check($timeInterval, $onlySameIp)
 {
     // since we don't store data of anonymous user, and anonymous user
     // are not allowed to post, we don't check
     if (!jAuth::isConnected()) {
         return false;
     }
     // check if the user is member of Admins (groupid 0) / Moderators (groupid 3)
     // if so, no need to stop the action of this group of users
     // FIXME we should check, not the group, but the rights !
     foreach (jAcl2DbUserGroup::getGroupList() as $grp) {
         if ($grp->id_aclgrp == 'admins' or $grp->id_aclgrp == 'moderators') {
             return false;
         }
     }
     $dao = jDao::get('havefnubb~posts');
     $rec = $dao->getMyLastEditedPost(jAuth::getUserSession()->id);
     if ($rec->member_last_post + $timeInterval > time()) {
         return false;
     }
     if ($onlySameIp && isset($_SERVER['REMOTE_ADDR']) && $rec->poster_ip != $_SERVER['REMOTE_ADDR']) {
         return false;
     }
     return true;
 }
Exemple #10
0
 /**
  * Send an email to the members that have subsribe to this post
  * @param integer $id of the subscribed post
  * @return void
  */
 public static function sendMail($id)
 {
     if (!jAuth::isConnected()) {
         return;
     }
     $dao = jDao::get(self::$daoSub);
     $memberDao = jDao::get('havefnubb~member');
     //get all the members that subscribe to this thread except "ME" !!!
     $records = $dao->findSubscribedPost($id, jAuth::getUserSession()->id);
     $gJConfig = jApp::config();
     // then send them a mail
     foreach ($records as $record) {
         //get all the member that subscribe to the thread id $id (called by hfnupost -> savereply )
         $thread = jClasses::getService('havefnubb~hfnuposts')->getThread($id);
         $post = jClasses::getService('havefnubb~hfnuposts')->getPost($thread->id_last_msg);
         //get the email of the member that subscribes this thread
         $member = $memberDao->getById($record->id_user);
         $subject = jLocale::get('havefnubb~post.new.comment.received') . " : " . $post->subject;
         $mail = new jMailer();
         $mail->From = $gJConfig->mailer['webmasterEmail'];
         $mail->FromName = $gJConfig->mailer['webmasterName'];
         $mail->Sender = $gJConfig->mailer['webmasterEmail'];
         $mail->Subject = $subject;
         $tpl = new jTpl();
         $tpl->assign('server', $_SERVER['SERVER_NAME']);
         $tpl->assign('post', $post);
         $tpl->assign('login', $member->login);
         $mail->Body = $tpl->fetch('havefnubb~new_comment_received', 'text');
         $mail->AddAddress($member->email);
         $mail->Send();
     }
 }
 protected function _beforeSaveUpdate($form, $form_daorec, $id)
 {
     if ($form->getData('flyer') == "") {
         $dao = jDao::get('events');
         $rec = $dao->get($form_daorec->id);
         $form_daorec->flyer = $rec->flyer;
     }
 }
 protected function _prepareTpl()
 {
     $id = jAuth::getUserSession()->id;
     $title = jLocale::get("jmessenger~message.msg.inbox");
     $dao = jDao::get($this->dao);
     $msg = $dao->getRecus($id);
     $this->_tpl->assign(compact('msg', 'id', 'title'));
 }
Exemple #13
0
 protected function _prepareTpl()
 {
     $id = $this->getParam("id", jAuth::getUserSession()->id);
     $title = jLocale::get("jmessenger~message.msg.archived");
     $dao = jDao::get($this->dao);
     $msg = $dao->getArchive($id);
     $send = true;
     $this->_tpl->assign(compact('msg', 'id', 'title', 'send'));
 }
Exemple #14
0
 public function verifyPassword($login, $password)
 {
     if (trim($password) == '') {
         return false;
     }
     $daouser = jDao::get($this->_params['dao'], $this->_params['profile']);
     $user = $daouser->getByLoginPassword($login, $this->cryptPassword($password));
     return $user ? $user : false;
 }
 protected function _markAsRead()
 {
     $dao = jDao::get($this->dao);
     $m = $dao->get($this->param("id", 0));
     if ($m && $m->id_for == jAuth::getUserSession()->id) {
         $m->isSeen = 1;
         $dao->update($m);
     }
 }
 function testEvents()
 {
     global $TEST_DAO_EVENTS;
     $TEST_DAO_EVENTS = array();
     $this->emptyTable('product_test');
     $dao = jDao::get('products_events');
     $prod1 = jDao::createRecord('products_events');
     $prod1->name = 'assiette';
     $prod1->price = 3.87;
     $prod2 = jDao::createRecord('products_events');
     $prod2->name = 'assiette';
     $prod2->price = 3.87;
     //$prod2 = clone $prod1;
     $res = $dao->insert($prod2);
     $this->assertTrue(isset($TEST_DAO_EVENTS['onDaoInsertBefore']));
     $this->assertTrue(isset($TEST_DAO_EVENTS['onDaoInsertAfter']));
     $this->assertEqual($TEST_DAO_EVENTS['onDaoInsertBefore']['dao'], 'jelix_tests~products_events');
     $this->assertEqual($TEST_DAO_EVENTS['onDaoInsertBefore']['record'], $prod1);
     $this->assertEqual($TEST_DAO_EVENTS['onDaoInsertAfter']['dao'], 'jelix_tests~products_events');
     $this->assertEqual($TEST_DAO_EVENTS['onDaoInsertAfter']['record'], $prod2);
     $prod2->name = 'nouvelle assiette';
     $prod = $dao->update($prod2);
     $this->assertTrue(isset($TEST_DAO_EVENTS['onDaoUpdateBefore']));
     $this->assertTrue(isset($TEST_DAO_EVENTS['onDaoUpdateAfter']));
     $this->assertEqual($TEST_DAO_EVENTS['onDaoUpdateBefore']['dao'], 'jelix_tests~products_events');
     $this->assertEqual($TEST_DAO_EVENTS['onDaoUpdateBefore']['record'], $prod2);
     $this->assertEqual($TEST_DAO_EVENTS['onDaoUpdateAfter']['dao'], 'jelix_tests~products_events');
     $this->assertEqual($TEST_DAO_EVENTS['onDaoUpdateAfter']['record'], $prod2);
     $dao->delete(0);
     // unexistant id
     $this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteBefore']));
     $this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteAfter']));
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteBefore']['dao'], 'jelix_tests~products_events');
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteBefore']['keys'], array('id' => 0));
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['dao'], 'jelix_tests~products_events');
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['keys'], array('id' => 0));
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['result'], 0);
     $dao->delete($prod2->id);
     $this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteBefore']));
     $this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteAfter']));
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteBefore']['dao'], 'jelix_tests~products_events');
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteBefore']['keys'], array('id' => $prod2->id));
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['dao'], 'jelix_tests~products_events');
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['keys'], array('id' => $prod2->id));
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteAfter']['result'], 1);
     $conditions = jDao::createConditions();
     $conditions->addCondition('id', '=', $prod2->id);
     $dao->deleteBy($conditions);
     $this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteByBefore']));
     $this->assertTrue(isset($TEST_DAO_EVENTS['onDaoDeleteByAfter']));
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteByBefore']['dao'], 'jelix_tests~products_events');
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteByBefore']['criterias'], $conditions);
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteByAfter']['dao'], 'jelix_tests~products_events');
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteByAfter']['result'], 0);
     $this->assertEqual($TEST_DAO_EVENTS['onDaoDeleteByAfter']['criterias'], $conditions);
 }
 /**
  * Search in Author
  * @param string $string the request to search
  * @param string $param the id forum in which to make the request
  * @return recordset
  */
 function searchInAuthors($string, $param = '', $page = 0, $limit)
 {
     $dao = jDao::get('havefnubb~posts');
     $records = $dao->findByAuthor($string, $page, $limit);
     $result = array();
     foreach ($records as $record) {
         $result[] = (array) $record;
     }
     return array('datas' => $result, 'total' => count($result));
 }
/**
 * function that display the nickname of the admin that censored the post
 */
function jtpl_function_html_censored_by($tpl, $id)
{
    $user = jDao::get('havefnubb~member')->getById($id);
    $str = jLocale::get('havefnubb~main.censored.by');
    if ($user->nickname != '') {
        echo $str . ' ' . $user->nickname;
    } else {
        echo $str . ' ' . $user->login;
    }
}
 public function onAuthNewUser($event)
 {
     $id = $event->getParam('user')->id;
     if (!$id or $id == 0) {
         return;
     }
     $request_date = date('Y-m-d H:i:s');
     $dao = jDao::get('havefnubb~member');
     $dao->updateNbMsgAfterCreatingAccount($id, $request_date);
 }
Exemple #20
0
 protected function _prepareTpl()
 {
     $id_cat = $this->param('id_cat');
     if (!$id_cat) {
         return;
     }
     $dao = jDao::get('havefnubb~forum');
     $forums = $dao->findParentByCatId($id_cat);
     $this->_tpl->assign('tableclass', 'forumList');
     $this->_tpl->assign('forums', $forums);
 }
 /**
  * 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();
 }
 /**
  * Function that updates member's datas
  */
 private function updateMember()
 {
     $daoUser = jDao::get('havefnubb~member');
     if (jAuth::isConnected()) {
         $id_user = jAuth::getUserSession()->id;
         $daoUser->updateNbMsg($id_user);
     } else {
         $id_user = 0;
     }
     $daoUser->updateLastPostedMsg($id_user, time());
 }
 /**
  * get the rank from the given nb of messages
  * @param integer $nbMsg nb of messages the user has
  * @return string $ranks the rank corresponding to the nb of messages
  */
 public static function getRank($nbMsg)
 {
     if (!isset(self::$ranks[$nbMsg])) {
         if (jDao::get('havefnubb~ranks')->getMyRank($nbMsg) === false) {
             self::$ranks[$nbMsg] = jDao::get('havefnubb~ranks')->getHigherRank();
         } else {
             self::$ranks[$nbMsg] = jDao::get('havefnubb~ranks')->getMyRank($nbMsg);
         }
     }
     return self::$ranks[$nbMsg];
 }
Exemple #24
0
 protected function _prepareTpl()
 {
     $records = array();
     $tb = jDao::get('post');
     $category_id = $this->param('id');
     $conditions = jDao::createConditions();
     $conditions->addCondition('published', '=', 'YES');
     $conditions->addCondition('category_id', '=', $category_id);
     $records = $tb->findBy($conditions)->fetchAll();
     $this->_tpl->assign('records', $records);
 }
 function createsave()
 {
     $news = jDao::createRecord('medsite~news');
     $news->sujet = $this->param('sujet');
     $news->texte = $this->param('texte');
     $news->news_date = $this->param('date');
     $dao = jDao::get('medsite~news');
     $dao->insert($news);
     $rep = $this->getResponse('redirect');
     $rep->action = 'medsite~default:index';
     return $rep;
 }
 /**
  * function to manage data before assigning to the template of its zone
  */
 protected function _prepareTpl()
 {
     $dao = jDao::get('havefnubb~threads_stats');
     $admin = (bool) $this->param('admin');
     //last 'x' posts
     if ($admin) {
         $lastPost = $dao->findLastPosts((int) jApp::config()->havefnubb['stats_nb_of_lastpost']);
     } else {
         $lastPost = $dao->findLastVisiblePosts((int) jApp::config()->havefnubb['stats_nb_of_lastpost']);
     }
     $this->_tpl->assign('lastPost', $lastPost);
 }
Exemple #27
0
 protected function _prepareTpl()
 {
     $dao = jDao::get('config');
     $this->_tpl->assign('config', $dao->findAll());
     $this->_tpl->assign('oneconf', $dao->get('foo'));
     $this->_tpl->assign('nombre', $dao->countAll());
     $this->_tpl->assign('nombrevalue', $dao->getCountValue());
     $cond = new jDaoConditions('or');
     $cond->addCondition('ckey', '=', 'foo');
     $cond->addCondition('ckey', '=', 'bar');
     $this->_tpl->assign('petitconfig', $dao->findBy($cond));
 }
 public function getPageOBJ($name)
 {
     $pageFacto = jDao::get('pages');
     $conditions = jDao::createConditions();
     $conditions->addCondition('name', '=', $name);
     $conditions->addCondition('language', '=', $GLOBALS['gJConfig']->locale);
     $text = "NOT FOUND";
     foreach ($pageFacto->findBy($conditions) as $page) {
         $text = $page;
     }
     return $text;
 }
 /**
  *
  */
 function read()
 {
     $rep = $this->getResponse('reader');
     $rep->bodyTpl = 'browser';
     $id = $this->intParam('id');
     $tb = jDao::get('link~link');
     $record = $tb->get($id);
     $content = file_get_contents($record->url);
     $content = str_replace('"/', '"' . $record->url . '/', $content);
     $rep->content = $content;
     return $rep;
 }
 protected function _prepareTpl()
 {
     $id = $this->param('id');
     $form = jForms::create('events');
     $form->initFromDao('events', $id);
     $this->_tpl->assign('id', $id);
     $this->_tpl->assign('form', $form);
     $this->_tpl->assign('record', jDao::get('events')->get($id));
     $this->_tpl->assign('editAction', 'events~events:preupdate');
     $this->_tpl->assign('deleteAction', 'events~events:delete');
     $this->_tpl->assign('listAction', 'events~events:index');
 }