function getList() { $dao =& CopixDAOFactory::create('copix:CopixCapability'); $sp =& CopixDAOFactory::createSearchParams(); $sp->orderBy('name_ccpb'); return $dao->findBy($sp); }
function _createContent(&$toReturn) { $tpl =& new CopixTpl(); $dao =& CopixDAOFactory::create('Comment'); $sp =& CopixDAOFactory::createSearchConditions(); $sp->addCondition('id_cmt', '=', $this->params['id']); $sp->addCondition('type_cmt', '=', $this->params['type']); $sp->addItemOrder('position_cmt', 'desc'); $arData = $dao->findBy($sp); if (count($arData) > 0) { $perPage = isset($this->params['perPage']) ? intval($this->params['perPage']) : intval(CopixConfig::get('comment|perPage')); $params = array('perPage' => $perPage, 'delta' => 5, 'recordSet' => $arData, 'template' => '|pager.tpl'); $Pager = CopixPager::Load($params); $tpl->assign('pager', $Pager->GetMultipage()); $tpl->assign('comments', $Pager->data); } $tpl->assign('back', $this->params['back']); $tpl->assign('id', $this->params['id']); $tpl->assign('type', $this->params['type']); $adminEnabled = CopixUserProfile::valueOf('site', 'siteAdmin') >= PROFILE_CCV_MODERATE; $tpl->assign('adminEnabled', $adminEnabled); $plugAuth =& $GLOBALS['COPIX']['COORD']->getPlugin('auth|auth'); $user =& $plugAuth->getUser(); $tpl->assign('login', $user->login); $toReturn = $tpl->fetch('comment.list.tpl'); return true; }
function getLignes() { $dao = CopixDAOFactory::create('adresseligne'); $criteres = CopixDAOFactory::createSearchConditions(); $criteres->addCondition('id_adresse', '=', $this->id); return $dao->findBy($criteres); }
/** * Etablissement d'un challenge, sur la base d'un identifiant SSO * * @author Christophe Beyer <*****@*****.**> * @since 2006/12/08 * @param integer $id_sso Id SSO * @return string résultat du challenge. -ERR xxx si erreur, +OK xxx si c'est bon */ public function challenge() { $id_sso = $this->getRequest('id_sso', null); if (!$id_sso) { echo "-ERR ACC: id_sso manquant"; } elseif (!preg_match('/^[0-9]+$/', $id_sso)) { echo "-ERR ACC: id_sso doit être un nombre"; } else { $token = false; $sql = "SELECT login FROM kernel_sso_users WHERE id_sso = {$id_sso}"; $sso = _doQuery($sql); //print_r($sso); if ($sso) { // On efface l'éventuel challenge courant $daoChallenges = CopixDAOFactory::create('sso|sso_challenges'); $daoChallenges->deleteByIdSso($id_sso); // On insère le nouveau challenge $token = randomkeys(CopixConfig::get('sso|in_encrypt_size')); $res = record('kernel_sso_challenges'); $res->id_sso = $id_sso; $res->challenge = $token; $res->date = mktime(); _ioDao('kernel_sso_challenges')->insert($record); //print_r($res); // if ($res->_idResult != 1) { echo "-ERR BDD: Erreur lors de l'enregistrement dans la base de données"; } //Kernel::deb (md5($token.'FobVVbarwb')); //die(); $token = "+OK " . $token; } else { echo "-ERR ACC: id_sso inexistant"; } echo $token; } return new CopixActionReturn(COPIX_AR_NONE, 0); }
/** * constructor. */ function CopixGroup($id) { //look for the capability values for the given group $this->id_cgrp = $id; if ($id !== null) { //check if the group exists. $daoGroup =& CopixDAOFactory::create('copix:CopixGroup'); $group =& $daoGroup->get($id); if ($group === null) { trigger_error('Given group does not exists'); } $this->description_cgrp = $group->description_cgrp; $this->name_cgrp = $group->name_cgrp; $this->all_cgrp = $group->all_cgrp; $this->known_cgrp = $group->known_cgrp; $daoCap =& CopixDAOFactory::create('copix:CopixGroupCapabilities'); $sp =& CopixDAOFactory::createSearchParams(); $sp->addCondition('id_cgrp', '=', $id); //load capabilities. $capabilities = $daoCap->findBy($sp); foreach ($capabilities as $capability) { $this->setCapability($capability->name_ccpb, $capability->value_cgcp); } //load logins $daoUserGroup =& CopixDAOFactory::create('copix:CopixUserGroup'); $sp =& CopixDAOFactory::createSearchParams(); $sp->addCondition('id_cgrp', '=', $id); $logins = $daoUserGroup->findBy($sp); //adds the logins in the object foreach ($logins as $login) { $this->addUsers($login->login_cusr); } } }
function _createContent(&$toReturn) { $tpl =& new CopixTpl(); $dao = CopixDAOFactory::create('emailcat'); $tpl->assign('listeEmailCat', $dao->findAll()); // retour de la fonction : $toReturn = $tpl->fetch('saisiePers.tpl'); return true; }
public function test() { $tpl = new CopixTpl(); $tpl->assign('TITLE_PAGE', "Logs"); $dao = CopixDAOFactory::create("logs|logs"); $data = $dao->lastLogin('admin'); $tpl->assign('MAIN', '<pre>' . print_r($data, true) . '</pre>'); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
function _createContent(&$toReturn) { $tpl =& new CopixTpl(); //getting the group list from the database. $daoGroups =& CopixDAOFactory::create('copix:CopixGroup'); $tpl->assign('groups', $daoGroups->findAll()); $toReturn = $tpl->fetch('profile.adminlist.tpl'); return true; }
function _createContent(&$toReturn) { $tpl =& new CopixTpl(); $dao = CopixDAOFactory::create('personne'); //Préparation de la liste des personnes $tpl->assign('listePers', $dao->findAll()); // retour de la fonction : $toReturn = $tpl->fetch('pers.tpl'); return true; }
function _createContent(&$toReturn) { //Création du sous template. $tpl =& new CopixTpl(); $daoGroups =& CopixDAOFactory::create('copix:CopixGroup'); $tpl->assign('groups', $daoGroups->findAll()); $tpl->assign('select', $this->params['select']); $tpl->assign('back', $this->params['back']); //fetch & end $toReturn = $tpl->fetch('group.select.tpl'); return true; }
function _createContent(&$toReturn) { $tpl =& new CopixTpl(); $dao = CopixDAOFactory::create('personne'); $criteres = CopixDAOFactory::createSearchConditions(); $idPers = $this->params['idPers']; $criteres->addCondition('id', '=', $idPers); $listePers = $dao->findBy($criteres); $tpl->assign('personne', $listePers[0]); $toReturn = $tpl->fetch('detailpers.tpl'); return true; }
public function getSwitchUser() { $login = _request('login'); if ($login != '') { $me_info = Kernel::getUserInfo("ME", 0); $animateurs_dao =& CopixDAOFactory::create("kernel|kernel_animateurs"); $animateur = $animateurs_dao->get($me_info['type'], $me_info['id']); $ien_dao =& CopixDAOFactory::create("kernel|kernel_ien"); $ien = $ien_dao->get($me_info['type'], $me_info['id']); // echo "<pre>"; print_r($ien); die("</pre>"); if (!$ien && (!$animateur || !isset($animateur->can_connect) || !$animateur->can_connect)) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('assistance||users', array('error' => 'forbidden'))); } $user_info = Kernel::getUserInfo("LOGIN", $login); // $user_info->user_id if (!$user_info) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('assistance||users', array('error' => 'forbidden'))); } $ok = false; $assistance_service =& CopixClassesFactory::Create('assistance|assistance'); $user_assistance = $assistance_service->getAssistanceUsers(); if (!$user_assistance) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('assistance||users', array('error' => 'forbidden'))); } foreach ($user_assistance as $ville_id => $ville) { foreach ($ville as $ecole_id => $ecole) { foreach ($ecole->personnels as $personnel_id => $personnel) { if ($personnel->id_copix == $user_info['user_id']) { $ok = $personnel->assistance; } } } } if (!$ok) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('assistance||users', array('error' => 'forbidden'))); } $currentUserLogin = _currentUser()->getLogin(); CopixSession::destroyNamespace('default'); _sessionSet('user_animateur', $currentUserLogin); _sessionSet('prisedecontrole_ien', $ien ? true : false); _currentUser()->login(array('login' => $login, 'assistance' => true)); $url_return = CopixUrl::get('kernel||doSelectHome'); } else { if ($session = _sessionGet('user_animateur')) { CopixSession::destroyNamespace('default'); //_sessionSet('user_animateur', null); _currentUser()->login(array('login' => $session, 'assistance' => true)); } $url_return = CopixUrl::get('assistance||users'); } return new CopixActionReturn(COPIX_AR_REDIRECT, $url_return); }
/** * Redefinition de la méthode delete par défaut du DAO * Cette méthode efface en cascade tous les enregistrements * associés à une personne lors de l'effacement de cette * personne. * @param $id L'id de la personne à effacer */ function delete($id) { $personne = $this->_compiled->get($id); $daoEmails = CopixDAOFactory::create('email'); $emails = $personne->getEmails(); foreach ($emails as $email) { $daoEmails->delete($email->id); } $daoAdresses = CopixDAOFactory::create('adresse'); $adresses = $personne->getAdresses(); foreach ($adresses as $adresse) { $daoAdresses->delete($adresse->id); } $this->_compiled->_compiled_delete($id); }
/** * @param $this->params['event'] string the event name */ function _createContent(&$toReturn) { //new tpl $tpl =& new CopixTpl(); //Search only for the given event. $dao =& CopixDAOFactory::create('CopixListener'); $sp = CopixDAOFactory::createSearchParams('event', '=', $this->params['event']); $sp = CopixDAOFactory::createSearchParams('kind', '=', 'zone'); $list = $dao->findBy($sp); //go through the founded listeners, asks for their processing foreach ($list as $toProcess) { $toReturn .= CopixZone::process($toProcess, $this->params); } return true; }
public function getHomePage() { if (!Kernel::isAdmin()) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||')); } $tpl = new CopixTpl(); $tplRegroupements = new CopixTpl(); // CopixHTMLHeader::addCSSLink (_resource("styles/module_grvilles.css")); // $tpl->assign ('TITLE_PAGE', CopixI18N::get ('grvilles|grvilles.module.titre')); $dao_grvilles = CopixDAOFactory::create("regroupements|grvilles"); $grvilles = $dao_grvilles->findAll(); $tplRegroupements->assign('GRVILLES', count($grvilles)); $dao_grecoles = CopixDAOFactory::create("regroupements|grecoles"); $grecoles = $dao_grecoles->findAll(); $tplRegroupements->assign('GRECOLES', count($grecoles)); $main = $tplRegroupements->fetch('default.tpl'); $tpl->assign('MAIN', $main); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
function _createContent(&$toReturn) { $tpl =& new CopixTpl(); $dao =& CopixDAOFactory::create('comment|comment'); $sp =& CopixDAOFactory::createSearchConditions(); $sp->addItemOrder('date_cmt', 'desc'); $sp->addItemOrder('position_cmt', 'desc'); $arComments = array(); $arComments = $dao->findby($sp); if (count($arComments) > 0) { $perPage = intval(CopixConfig::get('comment|quickAdminPerPage')); $params = array('perPage' => $perPage, 'delta' => 5, 'recordSet' => $arComments, 'template' => '|pager.tpl'); $pager = CopixPager::Load($params); $tpl->assign('pager', $pager->GetMultipage()); $tpl->assign('comments', $pager->data); } $toReturn = $lastComments === array() ? '' : $tpl->fetch('comment.quickadmin.tpl'); return true; }
/** * The profile manager. */ function CopixProfile($login) { $daoGroup =& CopixDAOFactory::create('copix:CopixUserGroup'); $sp =& CopixDAOFactory::createSearchParams(); //specific groups. $sp->addCondition('login_cusr', '=', $login); $groups = $daoGroup->findBy($sp); foreach ($groups as $group) { $this->_groups[$group->id_cgrp] =& new CopixGroup($group->id_cgrp); } //public or known user's groups $daoGroup =& CopixDAOFactory::create('copix:CopixGroup'); $sp =& CopixDAOFactory::createSearchParams(); $sp->addCondition('all_cgrp', '=', 1); if ($login !== null) { $sp->addCondition('known_cgrp', '=', 1, 'or'); } $groups = $daoGroup->findBy($sp); foreach ($groups as $group) { $this->_groups[$group->id_cgrp] =& new CopixGroup($group->id_cgrp); } }
function smarty_function_commentthis($params, &$smarty) { extract($params); if (empty($displaytype)) { $displaytype = 'list'; } if (empty($type)) { $smarty->trigger_error('commentthis: missing type parameter'); } if (empty($id)) { $smarty->trigger_error('commentthis: missing id parameter'); } if (empty($dest)) { $dest = CopixUrl::get('comment||getList', array('type' => $type, 'id' => $id, 'back' => $back)); } $dao =& CopixDAOFactory::create('comment|Comment'); $services =& CopixClassesFactory::create('comment|commentservices'); $services->enableComment($id, $type); switch ($displaytype) { case 'link': $nbComment = $dao->getNbComment($id, $type); $toReturn = '<a href=' . $dest . '>' . $nbComment . ' '; $toReturn .= $nbComment > 1 ? CopixI18N::get('comment|comment.messages.comments') : CopixI18N::get('comment|comment.messages.comment'); $toReturn .= '</a>'; break; case 'form': $back = CopixUrl::getCurrentUrl(); CopixActionGroup::process('comment|comment::doPrepareAdd', array('type' => $type, 'id' => $id, 'back' => $back)); $toEdit = CopixActionGroup::process('comment|comment::_getSessionComment'); $toReturn = CopixZone::process('comment|AddComment', array('toEdit' => $toEdit)); break; case 'list': default: $toReturn = CopixZone::process('comment|CommentList', array('type' => $type, 'id' => $id)); break; } return $toReturn; }
/** * getRoles * * Affiche le menu des rôles d'utilisateurs * * @package Comptes * @author Frédéric Mossmann <*****@*****.**> */ public function getRoles() { if (!Kernel::isAdmin()) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||')); } $this->menu = array(); if (Kernel::isAdmin() || _currentUser()->hasAssistance('can_comptes')) { if (CopixConfig::exists('kernel|gestionAutonomeEnabled') && CopixConfig::get('kernel|gestionAutonomeEnabled')) { $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getUsers'), 'url' => CopixUrl::get('gestionautonome||showTree'), 'type' => 'users'); } else { $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getUsers'), 'url' => CopixUrl::get('comptes||'), 'type' => 'users'); } $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getExt'), 'url' => CopixUrl::get('comptes||getUserExt'), 'type' => 'acl'); } if (Kernel::isAdmin()) { $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.getRoles'), 'url' => CopixUrl::get('comptes||getRoles'), 'type' => 'acl', 'current' => 'current'); $this->menu[] = array('txt' => CopixI18N::get('comptes|comptes.menu.manageGrades'), 'url' => CopixUrl::get('gestionautonome||manageGrades'), 'type' => 'agendalist'); } $tpl = new CopixTpl(); $tplRegroupements = new CopixTpl(); // CopixHTMLHeader::addCSSLink (_resource("styles/module_grvilles.css")); // $tpl->assign ('TITLE_PAGE', CopixI18N::get ('grvilles|grvilles.module.titre')); $dao_grvilles = CopixDAOFactory::create("regroupements|grvilles"); $grvilles = $dao_grvilles->findAll(); $tplRegroupements->assign('GRVILLES', count($grvilles)); $dao_grecoles = CopixDAOFactory::create("regroupements|grecoles"); $grecoles = $dao_grecoles->findAll(); $tplRegroupements->assign('GRECOLES', count($grecoles)); $main = $tplRegroupements->fetch('roles-default.tpl'); $tpl->assign('TITLE_PAGE', CopixI18N::get('comptes.moduleDescription') . " » " . CopixI18N::get('comptes.title.roles')); $tpl->assign('MAIN', $main); $tpl->assign('MENU', $this->menu); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
/** * Store data * * @access private */ function storeData($entityName) { $_entityName = $entityName; $_httpRequest =& HttpRequest::instance(); $_session =& HttpSession::instance(); $_tagged = $_session->getAttribute('TAGGED'); $_index = $_session->getAttribute('INDEX'); $_create = $_index < 0; $_next = false; if ($_httpRequest->getAttribute('accept')) { $_httpRequest->removeAttribute('accept'); $_new = $_httpRequest->getAttribute('ENTITY'); foreach ($_session->getAttribute('ENTITY') as $_key => $_value) { $_old[$_key] = $_value; } $_equal = true; foreach ($_new as $_key => $_value) { if ($_value !== $_old[$_key]) { $_updated[$_key] = $_value; $_equal = false; } else { $_updated[$_key] = $_old[$_key]; } } if (!$_equal) { $_dao =& CopixDAOFactory::create($_entityName); if ($_create) { $_entity =& CopixDAOFactory::createRecord($_entityName); foreach ($_updated as $_key => $_value) { $_entity->{$_key} = $_value; } $_dao->insert($_entity); $_connection =& CopixDbFactory::getConnection(); $_tagged[] = $_connection->lastId(); } else { // update $_dlname = 'get' . $_entityName . 'DataList'; $_dataList = $this->{$_dlname}(); $_idLabel = $_dataList['id']['var']; $_entity = $_dao->get($_updated[$_idLabel]); foreach ($_updated as $_key => $_value) { $_entity->{$_key} = $_value; } $_dao->update($_entity); } } ++$_index; // next one ? $_next = $_create || $_index < sizeOf($_tagged); } elseif ($_httpRequest->getAttribute('cancel')) { $_httpRequest->removeAttribute('cancel'); ++$_index; // next one ? $_next = !$_create && $_index < sizeOf($_tagged); } else { // always return to the list } if ($_next) { $_session->setAttribute('INDEX', $_index); $_httpRequest->removeAttribute('ENTITY'); $_forward = $_create ? 'create' : 'update'; $_httpRequest->setAttribute($_forward, $_forward); // $_httpRequest->setAttribute('TAGGED', $_tagged); // TODO: la méthode CopixUrl::getUrl ne gère pas correctement les tableaux, d'où : foreach ($_tagged as $_key => $_Id) { $_httpRequest->setAttribute('TAGGED[' . $_key . ']', $_Id); } $_requestUrl = new ProjectUrl('manage' . $_entityName . 'Data', null, 'workflow', $_httpRequest->toArray()); } else { $_requestUrl = new ProjectUrl('show' . $_entityName . 'List', null, 'workflow'); } return new CopixActionReturn(COPIX_AR_REDIRECT, $_requestUrl->getUrl(false)); }
/** * Ajout d'une info supplementaire * * @author Christophe Beyer <*****@*****.**> * @since 2008/01/30 * @param integer $id Id de la procedure */ public function insertInfoSupp() { $id = $this->getRequest('id', null); $info_message = $this->getRequest('info_message', null); $info_commentaire = $this->getRequest('info_commentaire', null); $visible = $this->getRequest('visible', null); $daoIntervention = CopixDAOFactory::create("intervention"); $daoInfoSupp = CopixDAOFactory::create("infosupp"); $criticErrors = $errors = array(); if ($id && ($rFiche = $daoIntervention->get($id))) { $title = $rFiche->objet; $mondroit = Kernel::getLevel("MOD_TELEPROCEDURES", $rFiche->type_teleprocedure); if (!TeleproceduresService::canMakeInTelep('ADD_COMMENT', $mondroit)) { $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights'); } } else { $criticErrors[] = CopixI18N::get('teleprocedures|teleprocedures.error.prob.telep'); } if ($criticErrors) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('teleprocedures||'))); } if ($info_message || $info_commentaire) { //$canCheckVisible = TeleproceduresService::canMakeInTelep('CHECK_VISIBLE', $mondroit); $rFiche->insertInfoSupp($info_message, $info_commentaire); } return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('|fiche', array('id' => $id))); }
public function getDelete() { if (!Kernel::isAdmin()) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||')); } $pUserType = _request('user_type'); $pUserId = _request('user_id'); if (!$pUserType || !$pUserId) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes|animateurs|list')); } $animateurs_dao =& CopixDAOFactory::create("kernel|kernel_animateurs"); // $animateurs2grville_dao = & CopixDAOFactory::create("kernel|kernel_animateurs2grville"); $animateurs2regroupements_dao =& CopixDAOFactory::create("kernel|kernel_animateurs2regroupements"); $animateurs_dao->delete($pUserType, $pUserId); // $animateurs2grville_dao->deleteByUser($pUserType, $pUserId); $animateurs2regroupements_dao->deleteByUser($pUserType, $pUserId); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('comptes|animateurs|list')); }
/** * Affichage de la fiche d'une ecole * * @author Christophe Beyer <*****@*****.**> * @since 2008/09/03 * @param integer $id Id de l'ecole */ public function blogs() { $id = $this->getRequest('id', null); $pAnnee = $this->getRequest('annee', null); // $ecoleDAO = CopixDAOFactory::create('kernel|kernel_bu_ecole'); $ficheDAO = CopixDAOFactory::create("fiches_ecoles"); $criticErrors = array(); if (!($rEcole = $ecoleDAO->get($id))) { $criticErrors[] = CopixI18N::get('fichesecoles.error.param'); } elseif (!FichesEcolesService::canMakeInFicheEcole($id, 'VIEW')) { $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights'); } if ($criticErrors) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('annuaire||'))); } $arClasses = AnnuaireService::getClassesInEcole($rEcole->numero, array('forceCanViewEns' => true, 'onlyWithBlog' => true, 'onlyWithBlogIsPublic' => 1, 'enseignant' => false, 'annee' => $pAnnee)); $rEcole->blog = getNodeBlog('BU_ECOLE', $rEcole->numero, array('is_public' => 1)); // Get vocabulary catalog to use $nodeVocabularyCatalogDAO = _ioDAO('kernel|kernel_i18n_node_vocabularycatalog'); $vocabularyCatalog = $nodeVocabularyCatalogDAO->getCatalogForNode('BU_ECOLE', $id); $tpl = new CopixTpl(); $tpl->assign('rEcole', $rEcole); $tpl->assign('arClasses', $arClasses); $tpl->assign('catalog', $vocabularyCatalog->id_vc); if ($anneeDebutBlogs = CopixConfig::get('fichesecoles|anneeDebutBlogs')) { $anneeFinBlogs = Kernel::getAnneeScolaireCourante()->id_as; //Kernel::deb("anneeDebutBlogs=$anneeDebutBlogs / anneeFinBlogs=$anneeFinBlogs"); if (!$pAnnee) { $pAnnee = $anneeFinBlogs; } if ($anneeFinBlogs > $anneeDebutBlogs) { $comboAnnees = CopixZone::process('kernel|combo_annees', array('name' => 'annee', 'selected' => $pAnnee, 'debut' => $anneeDebutBlogs, 'fin' => $anneeFinBlogs, 'extra2' => 'onChange="ficheViewBlogs(' . $id . ',this.options[this.selectedIndex].value);"')); $tpl->assign('comboAnnees', $comboAnnees); } } $result = $tpl->fetch('blogs.tpl'); header('Content-type: text/html; charset=utf-8'); //echo utf8_encode($result); echo $result; return new CopixActionReturn(COPIX_AR_NONE, 0); }
function _saveUsers($toSave) { $daoUserGroup =& CopixDAOFactory::create('copix:CopixUserGroup'); $groupUser =& CopixDAOFactory::createRecord('copix:CopixUserGroup'); $groupUser->id_cgrp = $toSave->id_cgrp; foreach ($toSave->getUsers() as $login) { $groupUser->login_cusr = $login; $daoUserGroup->insert($groupUser); } }
/** * Téléchargement d'une pièce jointe dans un classeur * * @author Christophe Beyer <*****@*****.**> * @since 2012/06/21 * @param integer $id Id du minimail de départ */ public function attachmentToClasseur() { //_dump($_POST); $this->addJs('js/iconito/module_classeur.js'); $this->addJs('js/iconito/module_minimail.js'); $this->addCss('styles/module_classeur.css'); _classInclude('classeur|classeurService'); _classInclude('kernel|Request'); $idUser = _currentUser()->getId(); $idMessage = _request("id"); $files = _request('files', array()); $destination = _request('destination'); $errors = array(); $daoFrom = _ioDAO("minimail|minimail_from"); $daoTo = CopixDAOFactory::create("minimail_to"); $message = $daoFrom->getMessage($idMessage); $canMake = $isRecv = $isSend = false; if ($message && $message->from_id == $idUser) { // Message qu'il a envoyé $canMake = $isSend = true; } else { // Il en est peut-être destinataire $canMake = $isRecv = $daoTo->selectDestFromIdAndToUser($idMessage, $idUser); // Test s'il est dans les destin } if (!$canMake) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('minimail.error.cantDisplay'), 'back' => CopixUrl::get('minimail||'))); } $menu = array(); $menu[] = array('txt' => CopixI18N::get('minimail.mess_recv'), 'url' => CopixUrl::get('minimail||getListRecv'), 'current' => $isRecv); $menu[] = array('txt' => CopixI18N::get('minimail.mess_send'), 'url' => CopixUrl::get('minimail||getListSend'), 'current' => $isSend); $menu[] = array('txt' => CopixI18N::get('minimail.mess_write'), 'url' => CopixUrl::get('minimail||getNewForm')); $ppo = new CopixPPO(); $ppo->TITLE_PAGE = $message; $ppo->MENU = $menu; $ppo->message = $message; //_dump(Request::isXmlHttpRequest()); if (Request::isPostMethod()) { $error = $success = array(); if (!$files) { $error[] = CopixI18N::get('minimail.attachmentToClasseur.error.noFiles'); } if ($destination) { list($ppo->destinationType, $ppo->destinationId) = explode('-', $destination); if ('classeur' == $ppo->destinationType) { $rClasseur = _ioDAO('classeur|classeur')->get($ppo->destinationId); } if ('dossier' == $ppo->destinationType) { if ($rDossier = _ioDAO('classeur|classeurdossier')->get($ppo->destinationId)) { $rClasseur = _ioDAO('classeur|classeur')->get($rDossier->classeur_id); } } } if (!$destination || !$rClasseur) { $error[] = CopixI18N::get('classeur|classeur.error.noDestination'); } if ($error) { $ppo->error = $error; return _arPPO($ppo, array('template' => 'attachmentToClasseur.tpl', 'mainTemplate' => 'main|main_popup.php')); } //_dump($destination); //_dump($rClasseur); $dir = realpath('./static/classeur') . '/' . $rClasseur->id . '-' . $rClasseur->cle . '/'; if (!file_exists($dir)) { mkdir($dir, 0755, true); } foreach ($files as $file) { $fichierPhysique = realpath("../var/data") . "/minimail/" . $file; $nomFichierPhysique = $file; $fichier = _record('classeur|classeurfichier'); $fichier->classeur_id = $rClasseur->id; $fichier->dossier_id = isset($rDossier) && $rDossier ? $rDossier->id : 0; $fichier->titre = MinimailService::getAttachmentName($file); $fichier->fichier = $nomFichierPhysique; $fichier->taille = filesize($fichierPhysique); $fichier->type = strtoupper(substr(strrchr($nomFichierPhysique, '.'), 1)); $fichier->cle = classeurService::createKey(); $fichier->date_upload = date('Y-m-d H:i:s'); $fichier->user_type = _currentUser()->getExtra('type'); $fichier->user_id = _currentUser()->getExtra('id'); _ioDAO('classeur|classeurfichier')->insert($fichier); if ($fichier->id > 0) { $nomClasseur = $rClasseur->id . '-' . $rClasseur->cle; $nomFichier = $fichier->id . '-' . $fichier->cle; $extension = strtolower(strrchr($nomFichierPhysique, '.')); if (copy($fichierPhysique, $dir . $fichier->id . '-' . $fichier->cle . $extension)) { $success[] = MinimailService::getAttachmentName($file); } else { $error[] = CopixI18N::get('minimail.attachmentToClasseur.error.moved', array(MinimailService::getAttachmentName($file))); } } else { $error[] = CopixI18N::get('minimail.attachmentToClasseur.error.creation', array(MinimailService::getAttachmentName($file))); } } if (count($success) > 0) { $dest = $rClasseur; if (isset($rDossier) && $rDossier) { $dest .= ' / ' . $rDossier; } if (1 == count($success)) { Kernel::setFlashMessage('success', CopixI18N::get('minimail.attachmentToClasseur.moved_1', array(implode(', ', $success), $dest))); } else { Kernel::setFlashMessage('success', CopixI18N::get('minimail.attachmentToClasseur.moved_N', array(implode(', ', $success), $dest))); } } if ($error) { Kernel::setFlashMessage('error', implode('<br />', $error)); } $ppo->ok = 1; //echo 'OK'; //return _arNone(); //return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('minimail||getMessage', array('id' => $idMessage))); } return _arPPO($ppo, array('template' => 'attachmentToClasseur.tpl', 'mainTemplate' => 'main|main_popup.php')); }
/** * Mise hors ligne d'un commentaire * * @author Christophe Beyer <*****@*****.**> * @since 2007/05/15 * @param integer $id_blog Id du blog * @param integer $id_bact Id de l'article * @param integer $id_bacc Id du commentaire * @todo V�rifier droits sur blog */ public function doOfflineComment() { $id_bacc = $this->getRequest('id_bacc', null); $id_bact = $this->getRequest('id_bact', null); $id_blog = $this->getRequest('id_blog', null); if ($id_bacc == null) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('blog|admin|listBlog'))); } $commentDAO =& CopixDAOFactory::create('blog|blogarticlecomment'); if (!($item = $commentDAO->get($id_bacc))) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotFindBlog'), 'back' => CopixUrl::get('blog|admin|listBlog'))); } $item->is_online = 0; $commentDAO->update($item); //print_r($item); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog|admin|listComment', array("id_blog" => $id_blog, "id_bact" => $id_bact))); }
/** * Afficher le logo. */ public function logo() { $id_blog = $this->getRequest('id_blog', null); if ($id_blog != null) { $blogDAO =& CopixDAOFactory::create('blog|blog'); if ($blog = $blogDAO->get($id_blog)) { $file = COPIX_VAR_PATH . CopixConfig::get('blog|logoPath') . $blog->logo_blog; //print_r("file=$file"); if (file_exists($file)) { $format_pict = strrchr($blog->logo_blog, '.'); header("Content-Type: image/" . substr($format_pict, 1)); readfile($file, 'r+'); return new CopixActionReturn(COPIX_AR_NONE, 0); } } } header("HTTP/1.0 404 Not Found"); return new CopixActionReturn(COPIX_AR_NONE, 0); }
/** * gets the list of capablities from a base path. */ function getList($fromPath = null) { $sp = CopixDAOFactory::createSearchParams(); //if given a path. if ($fromPath !== null) { $sp->addCondition('name_ccpt', 'like', $fromPath . '|%'); } //search $dao =& CopixDAOFactory::create('copix:CopixCapabilityPath'); $results = $dao->findBy($sp); //we only wants names $toReturn = array(); foreach ($results as $cap) { $toReturn[] = $cap->name_ccpt; } //we're gonna put the list in the correct order now return $toReturn; }
public function getGroup() { if (!Kernel::isAdmin()) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||')); } $tpl = new CopixTpl(); $tplGrVilles = new CopixTpl(); CopixHTMLHeader::addCSSLink(_resource("styles/module_regroupements.css")); $regroupements_service =& CopixClassesFactory::Create('regroupements|regroupements'); $tpl->assign('TITLE_PAGE', CopixI18N::get('regroupements|regroupements.villes.titre')); $tpl->assign('MENU', $regroupements_service->getMenu()); $dao_grvilles_gr2ville = CopixDAOFactory::create("regroupements|grvilles_gr2ville"); $dao_grvilles = CopixDAOFactory::create("regroupements|grvilles"); $dao_villes = CopixDAOFactory::create("kernel|kernel_tree_vil"); $villes = $dao_villes->findAll(); $tplGrVilles->assign('villes', $villes); if (_request("delete")) { $dao_grvilles->delete(_request("delete")); $dao_grvilles_gr2ville->deleteByGroupe(_request("delete")); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|')); } if (_request("save") && _request("save") == 1) { $date = date("Y-m-d H:i:s"); $user = Kernel::getUserInfo(); if (_request("form_id") > 0) { $grvilles_infos = $dao_grvilles->get(_request("form_id")); $grvilles_infos->nom = _request("form_nom"); $grvilles_infos->updated_at = $date; $grvilles_infos->updated_by = $user['login']; $dao_grvilles->update($grvilles_infos); $dao_grvilles_gr2ville->deleteByGroupe(_request("form_id")); } else { $grvilles_infos = CopixDAOFactory::createRecord("regroupements|grvilles"); $grvilles_infos->nom = _request("form_nom"); if ($grvilles_infos->nom == '') { $grvilles_infos->nom = 'Sans nom'; } $grvilles_infos->updated_at = date("Y-m-d H:i:s"); $grvilles_infos->updated_by = $user['login']; $dao_grvilles->insert($grvilles_infos); } $grvilles_gr2ville = _record("regroupements|grvilles_gr2ville"); $grvilles_gr2ville->id_groupe = $grvilles_infos->id; $grvilles_gr2ville->updated_at = $date; $grvilles_gr2ville->updated_by = $user['login']; foreach ($villes as $ville) { if (_request("ville_" . $ville->vil_id_vi) == 1) { $grvilles_gr2ville->id_ville = $ville->vil_id_vi; _dao("regroupements|grvilles_gr2ville")->insert($grvilles_gr2ville); } } if (_request("form_id") == 0) { return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('regroupements|villes|', array('groupe' => $grvilles_infos->id))); } } if (_request("groupe")) { $tplGrVilles->assign('grvilles_id', _request("groupe")); $tplGrVilles->assign('grvilles_form', true); if (_request("groupe") > 0) { // Edition d'un groupe $grvilles_infos = $dao_grvilles->get(_request("groupe")); $grvilles_villes_raw = $dao_grvilles_gr2ville->findByGroupe(_request("groupe")); // Tableau indexé par id de ville $grvilles_villes = array(); foreach ($grvilles_villes_raw as $grvilles_villes_item) { $grvilles_villes[$grvilles_villes_item->id_ville] = $grvilles_villes_item; } $tplGrVilles->assign('grvilles_infos', $grvilles_infos); $tplGrVilles->assign('grvilles_villes', $grvilles_villes); } else { // Création d'un nouveau groupe } } $grvilles_list = $dao_grvilles->findAll(); // print_r($grvilles_list); $tplGrVilles->assign('grvilles_list', $grvilles_list); $main = $tplGrVilles->fetch('getgrvilles.tpl'); $tpl->assign('MAIN', $main); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); }
/** * gets the list of capablities from a base path. */ function getList($fromPath = null) { $sp = CopixDAOFactory::createSearchParams(); //if given a path. if ($fromPath !== null) { $sp->addCondition('name_ccpb', 'like', $fromPath . '|%'); } $sp->orderBy('name_ccpb'); //search $dao =& CopixDAOFactory::create('copix:CopixCapability'); $results = $dao->findBy($sp); //we only wants names $toReturn = array(); foreach ($results as $cap) { if ($this->checkBelongsTo($fromPath, $cap->name_ccpb)) { //check if matches. $toReturn[] = $cap->name_ccpb; } } //we're gonna put the list in the correct order now return $toReturn; }