function index()
 {
     $offset = $this->intParam($this->offsetParameterName, 0, true);
     $rep = $this->_getResponse();
     $dao = jDao::get($this->dao, $this->dbProfile);
     $cond = jDao::createConditions();
     $this->_indexSetConditions($cond);
     $results = $dao->findBy($cond, $offset, $this->listPageSize);
     $pk = $dao->getPrimaryKeyNames();
     $form = $this->_createForm($this->pseudoFormId);
     $tpl = new jTpl();
     $tpl->assign('list', $results);
     $tpl->assign('primarykey', $pk[0]);
     if (count($this->propertiesForList)) {
         $prop = $this->propertiesForList;
     } else {
         $prop = array_keys($dao->getProperties());
     }
     $tpl->assign('properties', $prop);
     $tpl->assign('controls', $form->getControls());
     $tpl->assign('editAction', $this->_getAction('preupdate'));
     $tpl->assign('createAction', $this->_getAction('precreate'));
     $tpl->assign('deleteAction', $this->_getAction('delete'));
     $tpl->assign('viewAction', $this->_getAction('view'));
     $tpl->assign('listAction', $this->_getAction('index'));
     $tpl->assign('listPageSize', $this->listPageSize);
     $tpl->assign('page', $offset > 0 ? $offset : null);
     $tpl->assign('recordCount', $dao->countBy($cond));
     $tpl->assign('offsetParameterName', $this->offsetParameterName);
     $this->_index($rep, $tpl);
     $rep->body->assign($this->templateAssign, $tpl->fetch($this->listTemplate));
     jForms::destroy($this->form, $this->pseudoFormId);
     return $rep;
 }
Пример #2
0
 /**
  * list all users
  */
 function index()
 {
     $offset = $this->intParam('offset', 0, true);
     $rep = $this->getResponse('html');
     if ($this->form == '') {
         $rep->body->assign('MAIN', 'no form defined in the auth plugin');
         return $rep;
     }
     $tpl = new jTpl();
     $dao = jDao::get($this->dao, $this->dbProfile);
     $cond = jDao::createConditions();
     $cond->addItemOrder('login', 'asc');
     $tpl->assign('list', $dao->findBy($cond, $offset, $this->listPageSize));
     $pk = $dao->getPrimaryKeyNames();
     $tpl->assign('primarykey', $pk[0]);
     $tpl->assign('controls', jForms::create($this->form, '___$$$___')->getControls());
     $tpl->assign('listPageSize', $this->listPageSize);
     $tpl->assign('page', $offset);
     $tpl->assign('recordCount', $dao->countAll());
     $tpl->assign('cancreate', jAcl2::check('auth.users.create'));
     $tpl->assign('canview', jAcl2::check('auth.users.view'));
     $rep->body->assign('MAIN', $tpl->fetch('crud_list'));
     jForms::destroy($this->form, '___$$$___');
     return $rep;
 }
Пример #3
0
 /**
  *
  */
 function read()
 {
     $rep = $this->getResponse('json');
     $liste = array();
     $page = $this->intParam('page', 1, true);
     //$page
     $count = $this->intParam('count', 10, true);
     //$count
     $filtre = $this->param('filter');
     $sorting = $this->param('sorting');
     $offset = ($page - 1) * $count;
     // instanciation de la factory
     $tb = jDao::get('link');
     if (empty($cb)) {
         $dt = new jDateTime();
         $filter = (array) json_decode($filtre);
         $sorting = (array) json_decode($sorting);
         $conditions = jDao::createConditions();
         foreach ($filter as $key => $value) {
             $conditions->addCondition($key, 'LIKE', '%' . $value . '%');
         }
         foreach ($sorting as $key => $value) {
             $conditions->addItemOrder($key, $value);
         }
         $records = $tb->findBy($conditions, $offset, $count)->fetchAll();
         $rep->data["Count"] = $tb->countBy($conditions);
         $rep->data['Items'] = $records;
     } else {
         $rep->data['Items'] = $tb->findAll()->fetchAll();
     }
     return $rep;
 }
Пример #4
0
 /**
  *
  */
 function index()
 {
     $rep = $this->getResponse('html');
     $groups = array();
     $o = new StdClass();
     $o->id_aclgrp = '-2';
     $o->name = jLocale::get('jacl2_admin~acl2.all.users.option');
     $o->grouptype = 0;
     $groups[] = $o;
     $o = new StdClass();
     $o->id_aclgrp = '-1';
     $o->name = jLocale::get('jacl2_admin~acl2.without.groups.option');
     $o->grouptype = 0;
     $groups[] = $o;
     foreach (jAcl2DbUserGroup::getGroupList() as $grp) {
         $groups[] = $grp;
     }
     $listPageSize = 15;
     $offset = $this->intParam('idx', 0, true);
     $grpid = $this->intParam('grpid', -2, true);
     $p = jAcl2Db::getProfil();
     if ($grpid == -2) {
         //all users
         $dao = jDao::get('jelix~jacl2groupsofuser', $p);
         $cond = jDao::createConditions();
         $cond->addCondition('grouptype', '=', 2);
         $rs = $dao->findBy($cond, $offset, $listPageSize);
         $usersCount = $dao->countBy($cond);
     } elseif ($grpid == -1) {
         //only those who have no groups
         $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM jacl2_user_group 
                 GROUP BY login HAVING nbgrp < 2 ORDER BY login';
         $cnx = jDb::getConnection($p);
         $rs = $cnx->query($sql);
         $usersCount = -1;
     } else {
         //in a specific group
         $dao = jDao::get('jelix~jacl2usergroup', $p);
         $rs = $dao->getUsersGroupLimit($grpid, $offset, $listPageSize);
         $usersCount = $dao->getUsersGroupCount($grpid);
     }
     $users = array();
     $dao2 = jDao::get('jelix~jacl2groupsofuser', $p);
     foreach ($rs as $u) {
         $u->groups = array();
         $gl = $dao2->getGroupsUser($u->login);
         foreach ($gl as $g) {
             if ($g->grouptype != 2) {
                 $u->groups[] = $g;
             }
         }
         $users[] = $u;
     }
     $tpl = new jTpl();
     $tpl->assign(compact('offset', 'grpid', 'listPageSize', 'groups', 'users', 'usersCount'));
     $rep->body->assign('MAIN', $tpl->fetch('users_list'));
     return $rep;
 }
Пример #5
0
 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);
 }
Пример #6
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);
 }
Пример #7
0
 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;
 }
Пример #8
0
 protected function getIdOfLastEvent()
 {
     $dao = jDao::get('events');
     $cond = jDao::createConditions();
     $cond->addItemOrder('date_debut', 'DESC');
     $cond->addCondition('language', '=', $GLOBALS['gJConfig']->locale);
     $results = $dao->findBy($cond);
     $ret = null;
     foreach ($results as $r) {
         $ret = $r->id;
     }
     return $ret;
 }
 /**
  * default searchEngineRun methode which make a search from the engine by querying the table define in the dao of the hfnusearch.ini.php file
  * @param object $event
  */
 function searchEngineRun($event)
 {
     $cleaner = jClasses::getService('hfnusearch~cleaner');
     $words = $cleaner->stemPhrase($event->getParam('string'));
     $page = (int) $event->getParam('page');
     $limit = (int) $event->getParam('limit');
     $id_forum = (int) $event->getParam('id_forum');
     // no words ; go back with nothing :P
     if (!$words) {
         return array('count' => 0, 'result' => array());
     }
     //1) open the config file
     $HfnuSearchConfig = parse_ini_file(jApp::configPath() . 'havefnu.search.ini.php', true);
     //2) get the dao we want to read
     $dataSource = $HfnuSearchConfig['dao'];
     //3) build an array with each one
     $dataSources = preg_split('/,/', $dataSource);
     foreach ($dataSources as $ds) {
         //4) get a factory of the current DAO
         $dao = jDao::get($ds);
         //getting the column name on which we need to make the query
         $indexSubject = $HfnuSearchConfig[$ds]['index_subject'];
         $indexMessage = $HfnuSearchConfig[$ds]['index_message'];
         //5) get all the record
         $conditions = jDao::createConditions();
         $conditions->startGroup('OR');
         if ($id_forum > 0) {
             $conditions->addCondition('id_forum', '=', $id_forum);
         }
         foreach ($words as $word) {
             $conditions->addCondition($indexSubject, 'LIKE', '%' . $word . '%');
             $conditions->addCondition($indexMessage, 'LIKE', '%' . $word . '%');
         }
         $conditions->endGroup();
         $allRecord = $dao->findBy($conditions);
         if ($page > 0 and $limit > 0) {
             $record = $dao->findBy($conditions, $page, $limit);
         } else {
             $record = $allRecord;
         }
         foreach ($record as $rec) {
             if (jAcl2::check('hfnu.admin.post')) {
                 $event->Add(array('SearchEngineResult' => $rec, 'SearchEngineResultTotal' => $allRecord->rowCount()));
             } elseif (jAcl2::check('hfnu.forum.view', 'forum' . $rec->id_forum) and $rec->status < 7) {
                 $event->Add(array('SearchEngineResult' => $rec, 'SearchEngineResultTotal' => $allRecord->rowCount()));
             }
         }
     }
 }
Пример #10
0
 /**
  *
  */
 function read()
 {
     $rep = $this->getResponse('json');
     $liste = array();
     $id = $this->intParam('id', null, true);
     $page = $this->intParam('page', 1, true);
     $rows = $this->intParam('rows', 10, true);
     $offset = ($page - 1) * $rows;
     // instanciation de la factory
     $tb = jDao::get("user");
     $conditions = jDao::createConditions();
     $conditions->addItemOrder('id', 'DESC');
     $records = $tb->findBy($conditions)->fetchAll();
     // $liste['total']=$userFactory->countAll();
     $rep->data["Items"] = $records;
     $rep->data["Count"] = $tb->countBy($conditions);
     return $rep;
 }
Пример #11
0
 function prepareToSave()
 {
     $tpl = new jTpl();
     $rep = $this->getResponse('html');
     if ($this->param('id') === null) {
         $form = jForms::fill('NewsLetter~news');
         $dao = jDao::get('NewsLetter~newsLetter');
         $r = jDao::createRecord('NewsLetter~newsLetter');
         $r->date_create = date("Y-m-d");
         $r->text = $form->getData('text');
         $dao->insert($r);
     } else {
         $id = $this->param('id');
         $dao = jDao::get('NewsLetter~newsLetter');
         $r = $dao->get($this->param('id'));
     }
     $actions = array();
     $emails_dao = jDao::get('emails');
     $conds = jDao::createConditions();
     $count = $emails_dao->countBy($conds);
     $email_rate = 2000;
     for ($i = 0; $i <= $count; $i += $email_rate) {
         $action = array();
         $action['inf'] = $i;
         $action['sup'] = $i + $email_rate;
         $action['url'] = 'send';
         $action['id'] = $r->id;
         $actions[] = $action;
     }
     $tpl->assign('actions', $actions);
     $tpl->assign('id', $r->id);
     $emailSrv = new EmailService();
     if ($emailSrv->nbEmailsToSend($r->id) == 0) {
         $emailSrv->resetLogs($r->id);
     }
     $tpl->assign('n_emails', $emailSrv->nbEmailsToSend($r->id));
     $tpl->assign('n_emails_sent', $emailSrv->nbEmailsSent($r->id));
     $tpl->assign('servers', $emailSrv->getServers());
     $tpl->assign('maxMailPerMin', $emailSrv->maxMailPerMin());
     $tpl->assign('maxMailPerDay', $emailSrv->maxMailPerDay());
     $rep->body->assign('MAIN', $tpl->fetch('prepare_sending'));
     return $rep;
 }
Пример #12
0
 /**
  *
  */
 function read()
 {
     $rep = $this->getResponse('json');
     $group_id = $this->intParam('group_id', null, true);
     $user_id = $this->intParam('user_id', null, true);
     //$liste=array();
     // instanciation de la factory
     $tb = jDao::get("user_group");
     $cond = jDao::createConditions();
     if (!empty($user_id)) {
         $cond->addCondition('user_id', '=', $user_id);
     }
     if (!empty($group_id)) {
         $cond->addCondition('group_id', '=', $group_id);
     }
     $records = $tb->findBy($cond)->fetchAll();
     $rep->data["Items"] = $records;
     $rep->data["Count"] = $tb->countBy($cond);
     return $rep;
 }
Пример #13
0
 /**
  *
  */
 function read()
 {
     $rep = $this->getResponse('json');
     $page = $this->intParam('page', 1, true);
     //$page
     $count = $this->intParam('count', 10, true);
     //$count
     $filtre = $this->param('filter');
     $sorting = $this->param('sorting');
     $cb = $this->param('cb');
     $offset = ($page - 1) * $count;
     // instanciation de la factory
     $tb = jDao::get('group_feature');
     if (empty($cb)) {
         $dt = new jDateTime();
         $filter = (array) json_decode($filtre);
         $sorting = (array) json_decode($sorting);
         //            $start = $this->adjust($start, '-',false);
         //            $end = $this->adjust($end, '-');
         $conditions = jDao::createConditions();
         //            $conditions->addCondition('createdate', '>=', $start);
         //            $conditions->addCondition('createdate', '<=', $end);
         foreach ($filter as $key => $value) {
             if ($key == 'group_id') {
                 $conditions->addCondition($key, '=', $value);
             } else {
                 $conditions->addCondition($key, 'LIKE', '%' . $value . '%');
             }
         }
         foreach ($sorting as $key => $value) {
             $conditions->addItemOrder($key, $value);
         }
         $records = $tb->findBy($conditions, $offset, $count)->fetchAll();
         $rep->data['Items'] = $records;
         $rep->data["Count"] = $tb->countBy($conditions);
     } else {
         $rep->data['Items'] = $tb->findAll()->fetchAll();
         $rep->data["Count"] = $tb->countAll();
     }
     return $rep;
 }
Пример #14
0
 /**
  *
  */
 function read()
 {
     $rep = $this->getResponse('json');
     $app = $this->param('app', null, true);
     $tb = jDao::get("param");
     $conditions = jDao::createConditions();
     if (!empty($app)) {
         $conditions->addCondition('app', '=', $app);
         $t = $tb->countBy($conditions);
         if ($t == 0) {
             $record = jDao::createRecord("param");
             $record->app = $app;
             $record->params = null;
             $record->user_id = jAuth::getUserSession()->id;
             $tb->insert($record);
         }
     }
     $record = $tb->findBy($conditions)->fetch();
     $record->params = (object) json_decode($record->params);
     $rep->data = $record;
     return $rep;
 }
Пример #15
0
 /**
  * list all records
  */
 function index()
 {
     $offset = $this->intParam($this->offsetParameterName, 0, true);
     $rep = $this->_getResponse();
     $dao = jDao::get($this->dao, $this->dbProfile);
     $keyActionDao = $this->_getAction($this->dao);
     if ($this->showPropertiesOrderLinks && count($this->propertiesForRecordsOrder)) {
         if (!isset($_SESSION['CRUD_LISTORDER'][$keyActionDao])) {
             $_SESSION['CRUD_LISTORDER'][$keyActionDao] = $this->propertiesForRecordsOrder;
         }
         if (($lo = $this->param('listorder')) && array_key_exists($lo, $this->propertiesForRecordsOrder)) {
             $listOrder = $_SESSION['CRUD_LISTORDER'][$keyActionDao];
             if (isset($listOrder[$lo]) && $listOrder[$lo] == 'asc') {
                 $listOrder[$lo] = 'desc';
             } elseif (isset($listOrder[$lo]) && $listOrder[$lo] == 'desc') {
                 unset($listOrder[$lo]);
             } else {
                 $listOrder[$lo] = 'asc';
             }
             $_SESSION['CRUD_LISTORDER'][$keyActionDao] = $listOrder;
         }
     }
     $cond = jDao::createConditions();
     $cond->addCondition($this->spkName, '=', $this->param($this->spkName));
     $this->_indexSetConditions($cond);
     $results = $dao->findBy($cond, $offset, $this->listPageSize);
     // we're using a form to have the portunity to have
     // labels for each columns.
     $form = jForms::create($this->form, $this->pseudoFormId);
     $tpl = new jTpl();
     $tpl->assign('list', $results);
     $tpl->assign('dpkName', $this->dpkName);
     $tpl->assign('spkName', $this->spkName);
     $tpl->assign('spk', $this->param($this->spkName));
     if (count($this->propertiesForList)) {
         $prop = $this->propertiesForList;
     } else {
         $prop = array_keys($dao->getProperties());
     }
     $tpl->assign('propertiesForListOrder', $this->propertiesForListOrder);
     $tpl->assign('sessionForListOrder', isset($_SESSION['CRUD_LISTORDER'][$keyActionDao]) ? $_SESSION['CRUD_LISTORDER'][$keyActionDao] : $this->propertiesForListOrder);
     $tpl->assign('properties', $prop);
     $tpl->assign('controls', $form->getControls());
     $tpl->assign('editAction', $this->_getAction('preupdate'));
     $tpl->assign('createAction', $this->_getAction('precreate'));
     $tpl->assign('deleteAction', $this->_getAction('delete'));
     $tpl->assign('viewAction', $this->_getAction('view'));
     $tpl->assign('listAction', $this->_getAction('index'));
     $tpl->assign('listPageSize', $this->listPageSize);
     $tpl->assign('page', $offset > 0 ? $offset : null);
     $tpl->assign('recordCount', $dao->countBy($cond));
     $tpl->assign('offsetParameterName', $this->offsetParameterName);
     $this->_index($rep, $tpl);
     $rep->body->assign($this->templateAssign, $tpl->fetch($this->listTemplate));
     jForms::destroy($this->form, $this->pseudoFormId);
     return $rep;
 }
Пример #16
0
 /**
  * Remove a section.
  * @return Redirect to the index.
  */
 function removeSection()
 {
     $repository = $this->param('repository');
     // Remove the section
     if (lizmap::removeRepository($repository)) {
         // Remove rights on this resource
         $daoright = jDao::get('jacl2db~jacl2rights', 'jacl2_profile');
         $conditions = jDao::createConditions();
         $conditions->addCondition('id_aclres', '=', $repository);
         $nbdeleted = $daoright->deleteBy($conditions);
         jMessage::add(jLocale::get("admin~admin.form.admin_section.message.data.removed") . " " . jLocale::get("admin~admin.form.admin_section.message.data.removed.groups.concerned", array($nbdeleted)));
     } else {
         jMessage::add(jLocale::get("admin~admin.form.admin_section.message.data.removed.failed"), 'error');
     }
     // Redirect to the index
     $rep = $this->getResponse("redirect");
     $rep->action = "admin~config:index";
     return $rep;
 }
Пример #17
0
 /**
  * save data of a control using a dao.
  *
  * The control must be a container like checkboxes or listbox with multiple attribute.
  * If the form contain a new record (no formId), you should call saveToDao before
  * in order to get a new id (the primary key of the new record), or you should get a new id
  * by an other way. then you must pass this primary key in the third argument.
  * If the form has already a formId, then it will be used as a primary key, unless
  * you give one in the third argument.
  *
  * The Dao should map to an "association table" : its primary key should be
  * the primary key stored in the formId + the field which will contain one of
  * the values of the control. If this order is not the same as defined into the dao,
  * you should provide the list of property names which corresponds to the primary key
  * in this order : properties for the formId, followed by the property which contains
  * the value.
  * All existing records which have the formid in their keys are deleted
  * before to insert new values.
  *
  * @param string $controlName  the name of the control
  * @param string $daoSelector the selector of a dao file
  * @param mixed  $primaryKey the primary key if the form have no id. (optional)
  * @param mixed  $primaryKeyNames list of field corresponding to primary keys (optional)
  * @param string $dbProfile the jDb profile to use with the dao
  * @see jDao
  */
 public function saveControlToDao($controlName, $daoSelector, $primaryKey = null, $primaryKeyNames = null, $dbProfile = '')
 {
     if (!$this->controls[$controlName]->isContainer()) {
         throw new jExceptionForms('jelix~formserr.control.not.container', array($controlName, $this->sel));
     }
     $values = $this->container->data[$controlName];
     if (!is_array($values) && $values != '') {
         throw new jExceptionForms('jelix~formserr.value.not.array', array($controlName, $this->sel));
     }
     if (!$this->container->formId && !$primaryKey) {
         throw new jExceptionForms('jelix~formserr.formid.undefined.for.dao', array($controlName, $this->sel));
     }
     if ($primaryKey === null) {
         $primaryKey = $this->container->formId;
     }
     if (!is_array($primaryKey)) {
         $primaryKey = array($primaryKey);
     }
     $dao = jDao::create($daoSelector, $dbProfile);
     $daorec = jDao::createRecord($daoSelector, $dbProfile);
     $conditions = jDao::createConditions();
     if ($primaryKeyNames) {
         $pkNamelist = $primaryKeyNames;
     } else {
         $pkNamelist = $dao->getPrimaryKeyNames();
     }
     foreach ($primaryKey as $k => $pk) {
         $conditions->addCondition($pkNamelist[$k], '=', $pk);
         $daorec->{$pkNamelist[$k]} = $pk;
     }
     $dao->deleteBy($conditions);
     if (is_array($values)) {
         $valuefield = $pkNamelist[$k + 1];
         foreach ($values as $value) {
             $daorec->{$valuefield} = $value;
             $dao->insert($daorec);
         }
     }
 }
Пример #18
0
 function rightres()
 {
     $rep = $this->getResponse('html');
     $groupid = $this->param('group', null);
     if ($groupid === null || $groupid == '') {
         $rep->body->assign('MAIN', '<p>invalid group.</p>');
         return $rep;
     }
     $daogroup = jDao::get('jacl2db~jacl2group', 'jacl2_profile');
     if ($groupid != '__anonymous') {
         $group = $daogroup->get($groupid);
         if (!$group) {
             $rep->body->assign('MAIN', '<p>invalid group.</p>');
             return $rep;
         }
         $groupname = $group->name;
     } else {
         $groupname = jLocale::get('jacl2db_admin~acl2.anonymous.group.name');
     }
     $rightsWithResources = array();
     $daorights = jDao::get('jacl2db~jacl2rights', 'jacl2_profile');
     $rs = $daorights->getRightsHavingRes($groupid);
     $hasRightsOnResources = false;
     foreach ($rs as $rec) {
         if (!isset($rightsWithResources[$rec->id_aclsbj])) {
             $rightsWithResources[$rec->id_aclsbj] = array();
         }
         $rightsWithResources[$rec->id_aclsbj][] = $rec;
         $hasRightsOnResources = true;
     }
     $subjects_localized = array();
     if (!empty($rightsWithResources)) {
         $conditions = jDao::createConditions();
         $conditions->addCondition('id_aclsbj', 'in', array_keys($rightsWithResources));
         foreach (jDao::get('jacl2db~jacl2subject', 'jacl2_profile')->findBy($conditions) as $rec) {
             $subjects_localized[$rec->id_aclsbj] = jLocale::get($rec->label_key);
         }
     }
     $tpl = new jTpl();
     $tpl->assign(compact('groupid', 'groupname', 'subjects_localized', 'rightsWithResources', 'hasRightsOnResources'));
     if (jAcl2::check('acl.group.modify')) {
         $rep->body->assign('MAIN', $tpl->fetch('group_rights_res'));
     } else {
         $rep->body->assign('MAIN', $tpl->fetch('group_rights_res_view'));
     }
     $rep->body->assign('selectedMenuItem', 'usersgroups');
     return $rep;
 }
 public function getDefaultMiniDockable()
 {
     jClasses::inc('view~lizmapMapDockItem');
     $dockable = array();
     $configOptions = $this->getOptions();
     $bp = jApp::config()->urlengine['basePath'];
     if ($this->hasLocateByLayer()) {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('locate', jLocale::get('view~map.locatemenu.title'), $tpl->fetch('view~map_locate'), 1);
     }
     if (property_exists($configOptions, 'geolocation') && $configOptions->geolocation == 'True') {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('geolocation', jLocale::get('view~map.geolocate.navbar.title'), $tpl->fetch('view~map_geolocation'), 2);
     }
     if (property_exists($configOptions, 'print') && $configOptions->print == 'True') {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('print', jLocale::get('view~map.print.navbar.title'), $tpl->fetch('view~map_print'), 3);
     }
     if (property_exists($configOptions, 'measure') && $configOptions->measure == 'True') {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('measure', jLocale::get('view~map.measure.navbar.title'), $tpl->fetch('view~map_measure'), 4);
     }
     if ($this->hasTooltipLayers()) {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('tooltip-layer', jLocale::get('view~map.tooltip.navbar.title'), $tpl->fetch('view~map_tooltip'), 5, '', '');
     }
     if ($this->hasTimemanagerLayers()) {
         $tpl = new jTpl();
         $dockable[] = new lizmapMapDockItem('timemanager', jLocale::get('view~map.timemanager.navbar.title'), $tpl->fetch('view~map_timemanager'), 6, '', $bp . 'js/timemanager.js');
     }
     // Permalink
     if (true) {
         // Get geobookmark if user is connected
         $gbCount = False;
         $gbList = Null;
         if (jAuth::isConnected()) {
             $juser = jAuth::getUserSession();
             $usr_login = $juser->login;
             $daogb = jDao::get('lizmap~geobookmark');
             $conditions = jDao::createConditions();
             $conditions->addCondition('login', '=', $usr_login);
             $conditions->addCondition('map', '=', $this->repository->getKey() . ':' . $this->getKey());
             $gbList = $daogb->findBy($conditions);
             $gbCount = $daogb->countBy($conditions);
         }
         $tpl = new jTpl();
         $tpl->assign('gbCount', $gbCount);
         $tpl->assign('gbList', $gbList);
         $gbContent = Null;
         if ($gbList) {
             $gbContent = $tpl->fetch('view~map_geobookmark');
         }
         $tpl = new jTpl();
         $tpl->assign('gbContent', $gbContent);
         $dockable[] = new lizmapMapDockItem('permaLink', jLocale::get('view~map.permalink.navbar.title'), $tpl->fetch('view~map_permalink'), 6);
     }
     return $dockable;
 }
 /**
  * list all records
  */
 function index()
 {
     $offset = $this->intParam($this->offsetParameterName, 0, true);
     $rep = $this->_getResponse();
     $dao = jDao::get($this->dao, $this->dbProfile);
     $cond = jDao::createConditions();
     $cond->addCondition($this->spkName, '=', $this->param($this->spkName));
     $this->_indexSetConditions($cond);
     $results = $dao->findBy($cond, $offset, $this->listPageSize);
     // we're using a form to have the portunity to have
     // labels for each columns.
     $form = jForms::create($this->form, $this->pseudoFormId);
     $tpl = new jTpl();
     $tpl->assign('list', $results);
     $tpl->assign('dpkName', $this->dpkName);
     $tpl->assign('spkName', $this->spkName);
     $tpl->assign('spk', $this->param($this->spkName));
     if (count($this->propertiesForList)) {
         $prop = $this->propertiesForList;
     } else {
         $prop = array_keys($dao->getProperties());
     }
     $tpl->assign('properties', $prop);
     $tpl->assign('controls', $form->getControls());
     $tpl->assign('editAction', $this->_getAction('preupdate'));
     $tpl->assign('createAction', $this->_getAction('precreate'));
     $tpl->assign('deleteAction', $this->_getAction('delete'));
     $tpl->assign('viewAction', $this->_getAction('view'));
     $tpl->assign('listAction', $this->_getAction('index'));
     $tpl->assign('listPageSize', $this->listPageSize);
     $tpl->assign('page', $offset > 0 ? $offset : null);
     $tpl->assign('recordCount', $dao->countBy($cond));
     $tpl->assign('offsetParameterName', $this->offsetParameterName);
     $this->_index($rep, $tpl);
     $rep->body->assign($this->templateAssign, $tpl->fetch($this->listTemplate));
     jForms::destroy($this->form, $this->pseudoFormId);
     return $rep;
 }
Пример #21
0
 function rightres()
 {
     $rep = $this->getResponse('html');
     $user = $this->param('user');
     if (!$user) {
         $rep->body->assign('MAIN', '<p>invalid user</p>');
         return $rep;
     }
     $daogroup = jDao::get('jacl2db~jacl2group', 'jacl2_profile');
     $group = $daogroup->getPrivateGroup($user);
     $rightsWithResources = array();
     $daorights = jDao::get('jacl2db~jacl2rights', 'jacl2_profile');
     $rs = $daorights->getRightsHavingRes($group->id_aclgrp);
     $hasRightsOnResources = false;
     foreach ($rs as $rec) {
         if (!isset($rightsWithResources[$rec->id_aclsbj])) {
             $rightsWithResources[$rec->id_aclsbj] = array();
         }
         $rightsWithResources[$rec->id_aclsbj][] = $rec;
         $hasRightsOnResources = true;
     }
     $subjects_localized = array();
     if (!empty($rightsWithResources)) {
         $conditions = jDao::createConditions();
         $conditions->addCondition('id_aclsbj', 'in', array_keys($rightsWithResources));
         foreach (jDao::get('jacl2db~jacl2subject', 'jacl2_profile')->findBy($conditions) as $rec) {
             $subjects_localized[$rec->id_aclsbj] = jLocale::get($rec->label_key);
         }
     }
     $tpl = new jTpl();
     $tpl->assign(compact('user', 'subjects_localized', 'rightsWithResources', 'hasRightsOnResources'));
     if (jAcl2::check('acl.user.modify')) {
         $rep->body->assign('MAIN', $tpl->fetch('user_rights_res'));
     } else {
         $rep->body->assign('MAIN', $tpl->fetch('user_rights_res_view'));
     }
     $rep->body->assign('selectedMenuItem', 'usersrights');
     return $rep;
 }
Пример #22
0
 /**
  * Export the detailed logs in CSV
  *
  * 
  */
 function export()
 {
     // Get logs
     $dao = jDao::get('lizmap~logDetail', 'lizlog');
     $nblogs = 0;
     $logs = Null;
     try {
         $logs = $dao->findAll();
         $conditions = jDao::createConditions();
         $nblogs = $dao->countBy($conditions);
     } catch (Exception $e) {
         $rep = $this->getResponse('redirect');
         jMessage::add('Error : ' . $e->getMessage(), 'error');
         $rep->action = 'admin~logs:index';
         return $rep;
     }
     // Récupération des colonnes
     $fetch = $logs->fetch();
     $columns = array();
     if ($nblogs > 0) {
         $fetchArray = get_object_vars($fetch);
         $columns = array_keys($fetchArray);
     }
     $rep = $this->getResponse('binary');
     $rep->mimeType = "text/csv";
     $rep->addHttpHeader("charset", "UTF-8");
     $rep->doDownload = True;
     $rep->fileName = "lizmap_logs.csv";
     $data = array();
     $data[] = '"' . implode('";"', $columns) . '"';
     foreach ($logs as $log) {
         $row = array();
         foreach ($columns as $column) {
             $row[] = $log->{$column};
         }
         $data[] = '"' . implode('";"', $row) . '"';
     }
     $rep->content = implode("\r\n", $data);
     return $rep;
 }
Пример #23
0
 function nbLogs($id)
 {
     $dao = jDao::get('emails_logs');
     $conditions = jDao::createConditions();
     $conditions->addCondition('id_newsLetter', '=', $id);
     return $dao->countBy($conditions);
 }
Пример #24
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);
 }
Пример #25
0
    function testDeleteBy()
    {
        $dao = jDao::create('products');
        $conditions = jDao::createConditions();
        $conditions->addCondition('id', '=', $this->prod2->id);
        $dao->deleteBy($conditions);
        $this->assertTrue($dao->countAll() == 1, 'countAll doesn\'t return 1');
        $this->records = array(array('id' => $this->prod3->id, 'name' => 'verre', 'price' => 2.43));
        $this->assertTableContainsRecords('product_test', $this->records);
        $res = $dao->findAll();
        $list = array();
        foreach ($res as $r) {
            $list[] = $r;
        }
        $this->assertEqual(count($list), 1, 'findAll doesn\'t return all products. %s ');
        $verif = '<array>
    <object>
        <string property="id" value="' . $this->prod3->id . '" />
        <string property="name" value="verre" />
        <string property="price" value="2.43" />
    </object>
</array>';
        $this->assertComplexIdenticalStr($list, $verif);
    }
Пример #26
0
 /**
  *
  */
 function index()
 {
     $rep = $this->getResponse('html');
     $groups = array();
     $o = new StdClass();
     $o->id_aclgrp = '-2';
     $o->name = jLocale::get('jacl2db_admin~acl2.all.users.option');
     $o->grouptype = 0;
     $groups[] = $o;
     $o = new StdClass();
     $o->id_aclgrp = '-1';
     $o->name = jLocale::get('jacl2db_admin~acl2.without.groups.option');
     $o->grouptype = 0;
     $groups[] = $o;
     foreach (jAcl2DbUserGroup::getGroupList() as $grp) {
         $groups[] = $grp;
     }
     $listPageSize = 15;
     $offset = $this->intParam('idx', 0, true);
     $grpid = $this->intParam('grpid', -2, true);
     $p = jAcl2Db::getProfile();
     if ($grpid == -2) {
         //all users
         $dao = jDao::get('jelix~jacl2groupsofuser', $p);
         $cond = jDao::createConditions();
         $cond->addCondition('grouptype', '=', 2);
         $rs = $dao->findBy($cond, $offset, $listPageSize);
         $usersCount = $dao->countBy($cond);
     } elseif ($grpid == -1) {
         $cnx = jDb::getConnection($p);
         //only those who have no groups
         if ($cnx->dbms != 'pgsql') {
             // with MYSQL 4.0.12, you must use an alias with the count to use it with HAVING
             $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM ' . $cnx->prefixTable('jacl2_user_group') . '
                     GROUP BY login HAVING nbgrp < 2 ORDER BY login';
         } else {
             // But PgSQL doesn't support the HAVING structure with an alias.
             $sql = 'SELECT login, count(id_aclgrp) as nbgrp FROM ' . $cnx->prefixTable('jacl2_user_group') . '
                     GROUP BY login HAVING count(id_aclgrp) < 2 ORDER BY login';
         }
         $rs = $cnx->query($sql);
         $usersCount = $rs->rowCount();
     } else {
         //in a specific group
         $dao = jDao::get('jelix~jacl2usergroup', $p);
         $rs = $dao->getUsersGroupLimit($grpid, $offset, $listPageSize);
         $usersCount = $dao->getUsersGroupCount($grpid);
     }
     $users = array();
     $dao2 = jDao::get('jelix~jacl2groupsofuser', $p);
     foreach ($rs as $u) {
         $u->groups = array();
         $gl = $dao2->getGroupsUser($u->login);
         foreach ($gl as $g) {
             if ($g->grouptype != 2) {
                 $u->groups[] = $g;
             }
         }
         $users[] = $u;
     }
     $tpl = new jTpl();
     $tpl->assign(compact('offset', 'grpid', 'listPageSize', 'groups', 'users', 'usersCount'));
     $rep->body->assign('MAIN', $tpl->fetch('users_list'));
     $rep->body->assign('selectedMenuItem', 'usersrights');
     return $rep;
 }
 /**
  * Dynamically update form by modifying the filter by login control
  *
  * @param object $form Jelix form to modify control.
  * @param string $save does the form will be used for update or insert.
  * @return modified form.
  */
 private function updateFormByLogin($form, $save)
 {
     if (!is_array($this->loginFilteredLayers)) {
         //&& $this->loginFilteredOveride )
         $this->filterDataByLogin($this->layerName);
     }
     if (is_array($this->loginFilteredLayers)) {
         $type = $this->loginFilteredLayers['type'];
         $attribute = $this->loginFilteredLayers['attribute'];
         // Check if a user is authenticated
         if (!jAuth::isConnected()) {
             return True;
         }
         $user = jAuth::getUserSession();
         if (!$this->loginFilteredOveride) {
             if ($type == 'login') {
                 $user = jAuth::getUserSession();
                 $form->setData($attribute, $user->login);
                 $form->setReadOnly($attribute, True);
             } else {
                 $oldCtrl = $form->getControl($attribute);
                 $userGroups = jAcl2DbUserGroup::getGroups();
                 $userGroups[] = 'all';
                 $uGroups = array();
                 foreach ($userGroups as $uGroup) {
                     if ($uGroup != 'users' and substr($uGroup, 0, 7) != "__priv_") {
                         $uGroups[$uGroup] = $uGroup;
                     }
                 }
                 $dataSource = new jFormsStaticDatasource();
                 $dataSource->data = $uGroups;
                 $ctrl = new jFormsControlMenulist($attribute);
                 $ctrl->required = true;
                 if ($oldCtrl != null) {
                     $ctrl->label = $oldCtrl->label;
                 } else {
                     $ctrl->label = $attribute;
                 }
                 $ctrl->datasource = $dataSource;
                 $value = null;
                 if ($oldCtrl != null) {
                     $value = $form->getData($attribute);
                     $form->removeControl($attribute);
                 }
                 $form->addControl($ctrl);
                 if ($value != null) {
                     $form->setData($attribute, $value);
                 }
             }
         } else {
             $oldCtrl = $form->getControl($attribute);
             $value = null;
             if ($oldCtrl != null) {
                 $value = $form->getData($attribute);
             }
             $data = array();
             if ($type == 'login') {
                 $plugin = jApp::coord()->getPlugin('auth');
                 if ($plugin->config['driver'] == 'Db') {
                     $authConfig = $plugin->config['Db'];
                     $dao = jDao::get($authConfig['dao'], $authConfig['profile']);
                     $cond = jDao::createConditions();
                     $cond->addItemOrder('login', 'asc');
                     $us = $dao->findBy($cond);
                     foreach ($us as $u) {
                         $data[$u->login] = $u->login;
                     }
                 }
             } else {
                 $gp = jAcl2DbUserGroup::getGroupList();
                 foreach ($gp as $g) {
                     if ($g->id_aclgrp != 'users') {
                         $data[$g->id_aclgrp] = $g->id_aclgrp;
                     }
                 }
                 $data['all'] = 'all';
             }
             $dataSource = new jFormsStaticDatasource();
             $dataSource->data = $data;
             $ctrl = new jFormsControlMenulist($attribute);
             $ctrl->required = true;
             if ($oldCtrl != null) {
                 $ctrl->label = $oldCtrl->label;
             } else {
                 $ctrl->label = $attribute;
             }
             $ctrl->datasource = $dataSource;
             $form->removeControl($attribute);
             $form->addControl($ctrl);
             if ($value != null) {
                 $form->setData($attribute, $value);
             } else {
                 if ($type == 'login') {
                     $form->setData($attribute, $user->login);
                 }
             }
         }
     }
     return True;
 }
 function getBookmarkParams()
 {
     $ok = True;
     // Get user
     $juser = jAuth::getUserSession();
     $usr_login = $juser->login;
     // Bookmark id
     $id = $this->intParam('id');
     // Conditions to get the bookmark
     $daogb = jDao::get('lizmap~geobookmark');
     $conditions = jDao::createConditions();
     $conditions->addCondition('login', '=', $usr_login);
     $conditions->addCondition('id', '=', $id);
     $gbCount = $daogb->countBy($conditions);
     if ($gbCount != 1) {
         $ok = False;
         jMessage::add('Wrong id given', 'error');
         return $this->error();
     } else {
         $gbList = $daogb->findBy($conditions);
         $gbParams = array();
         foreach ($gbList as $gb) {
             $gbParams = json_decode(htmlspecialchars_decode($gb->params, ENT_QUOTES));
         }
         $rep = $this->getResponse('json');
         $rep->data = $gbParams;
         return $rep;
     }
 }
Пример #29
0
 /**
  * list all users
  */
 function index()
 {
     $offset = $this->intParam('offset', 0, true);
     $rep = $this->getResponse('html');
     if ($this->form == '') {
         $rep->body->assign('MAIN', 'no form defined in the auth plugin');
         return $rep;
     }
     $tpl = new jTpl();
     $dao = jDao::get($this->dao, $this->dbProfile);
     if (isset($_SESSION['AUTHDB_CRUD_LISTORDER'])) {
         $listOrder = $_SESSION['AUTHDB_CRUD_LISTORDER'];
     } else {
         $listOrder = array('login' => 'asc');
     }
     if (($lo = $this->param('listorder')) && in_array($lo, $this->propertiesForList)) {
         if (isset($listOrder[$lo]) && $listOrder[$lo] == 'asc') {
             $listOrder[$lo] = 'desc';
         } elseif (isset($listOrder[$lo]) && $listOrder[$lo] == 'desc') {
             unset($listOrder[$lo]);
         } else {
             $listOrder[$lo] = 'asc';
         }
         $_SESSION['AUTHDB_CRUD_LISTORDER'] = $listOrder;
     }
     $cond = jDao::createConditions();
     foreach ($listOrder as $name => $order) {
         $cond->addItemOrder($name, $order);
     }
     $filter = trim($this->param('filter'));
     if ($filter && count($this->filteredProperties)) {
         if (count($this->filteredProperties) == 1) {
             $cond->addCondition($this->filteredProperties[0], 'LIKE', '%' . $filter . '%');
         } else {
             $cond->startGroup('OR');
             foreach ($this->filteredProperties as $prop) {
                 $cond->addCondition($prop, 'LIKE', '%' . $filter . '%');
             }
             $cond->endGroup();
         }
     }
     $tpl->assign('list', $dao->findBy($cond, $offset, $this->listPageSize));
     $pk = $dao->getPrimaryKeyNames();
     $tpl->assign('primarykey', $pk[0]);
     $tpl->assign('showfilter', count($this->filteredProperties));
     $tpl->assign('filter', $filter);
     $tpl->assign('listOrder', $listOrder);
     $tpl->assign('propertiesList', $this->propertiesForList);
     $tpl->assign('controls', jForms::create($this->form, '___$$$___')->getControls());
     $tpl->assign('listPageSize', $this->listPageSize);
     $tpl->assign('page', $offset);
     $tpl->assign('recordCount', $dao->countAll());
     $tpl->assign('cancreate', jAcl2::check('auth.users.create'));
     $tpl->assign('canview', jAcl2::check('auth.users.view'));
     $rep->body->assign('MAIN', $tpl->fetch('crud_list'));
     $rep->body->assign('selectedMenuItem', 'users');
     jForms::destroy($this->form, '___$$$___');
     return $rep;
 }
Пример #30
0
 function getSubjectsByTags($tags, $scope)
 {
     // Get tags
     $tags = explode(',', $tags);
     // Count tags
     $tags_cnter = count($tags);
     // Get all tags_tagged for the given tags
     $ttag_fact = jDao::get($this->dao_object_tags);
     $conditions = jDao::createConditions();
     $conditions->addCondition('tt_scope_id', '=', $scope);
     $conditions->startGroup('OR');
     foreach ($tags as $tag) {
         $conditions->addCondition('tag_name', '=', trim($tag));
     }
     $conditions->endGroup();
     $ttags = $ttag_fact->findBy($conditions);
     // We have to count the apparition of each subject_id
     $ttags_cnter = array();
     foreach ($ttags as $ttag) {
         // Init
         if (!isset($ttags_cnter[$ttag->tt_subject_id])) {
             $ttags_cnter[$ttag->tt_subject_id] = 0;
         }
         // Count
         $ttags_cnter[$ttag->tt_subject_id]++;
     }
     // Keep only subject_id which appear $tags_cnter times
     return array_keys($ttags_cnter, $tags_cnter);
 }