public function _createContent(&$toReturn)
 {
     //Getting the user.
     //Create Services, and DAO
     $tpl = new CopixTpl();
     $id_blog = $this->getParam('id_blog', '');
     $tpl->assign('blog', $this->getParam('blog', null));
     $tpl->assign('id_blog', $id_blog);
     $tpl->assign('kind', $this->getParam('kind', ''));
     $tpl->assign('tabBlogFunctions', $this->getParam('tabBlogFunctions', null));
     $tpl->assign('can_format_articles', CopixConfig::get('blog|blog.default.can_format_articles'));
     $tpl->assign('RESULT', $this->getParam('RESULT', ''));
     $parent = Kernel::getModParentInfo("MOD_BLOG", $id_blog);
     if ($parent) {
         $mods = Kernel::getModEnabled($parent['type'], $parent['id'], '', 0, 1);
         // _dump($mods);
         $mods = Kernel::filterModuleList($mods, 'MOD_MAGICMAIL');
         if (count($mods)) {
             $magicmail_infos = _dao('module_magicmail')->get($mods[0]->module_id);
             $tpl->assign('magicmail_infos', $magicmail_infos);
             // _dump($magicmail_infos);
             /*
                'id' => '32',
                'login' => 'cepapeti',
                'domain' => 'magicmail.iconito.fr',
             */
         }
     }
     // retour de la fonction :
     $toReturn = $tpl->fetch('blog.show.tpl');
     return true;
 }
 public function getSso()
 {
     $id = $this->getRequest('id', null);
     if (!$id) {
         // Récupération des infos de l'utilisateur.
         $userInfo = Kernel::getUserInfo();
         // Création des modules inexistants.
         Kernel::createMissingModules($userInfo["type"], $userInfo["id"]);
         // Liste des modules activés.
         $modsList = Kernel::getModEnabled($userInfo["type"], $userInfo["id"]);
         foreach ($modsList as $modInfo) {
             if ($modInfo->module_type == "MOD_SSO" && $modInfo->module_id) {
                 $urlReturn = CopixUrl::get('sso||getSso', array('id' => $modInfo->module_id));
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn);
             }
         }
     }
     if (!$id) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => 'Problème', 'back' => CopixUrl::get('||')));
     }
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', CopixI18N::get('sso.title.servext'));
     $dao = CopixDAOFactory::create("sso|sso_auth");
     // $all = $dao->findAll();
     $all = $dao->findBySso($id);
     $tpl->assign('MAIN', CopixZone::process('sso|SsoAuthList', array('list' => $all, 'id' => _request("id"))));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
Пример #3
0
 public function getModules()
 {
     $my_modules = array();
     $nodes = Kernel::getMyNodes();
     if (sizeof($nodes)) {
         foreach ($nodes as $node_key => $node) {
             $modules = Kernel::getModEnabled($node->type, $node->id, _currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
             foreach ($modules as $modules_key => $module) {
                 if ($module->module_type != "MOD_PREFS" && preg_match('#^MOD_(.+)$#', $module->module_type, $regs)) {
                     $mod_tmp = new CopixPPO();
                     $mod_tmp->type = $module->module_type;
                     $mod_tmp->nom = $module->module_nom;
                     $mod_tmp->rep = strtolower($regs[1]);
                     $my_modules[$module->module_type] = $mod_tmp;
                     unset($mod_tmp);
                 }
             }
         }
     }
     ksort($my_modules);
     $pref_module['MOD_PREFS'] = new CopixPPO();
     $pref_module['MOD_PREFS']->type = 'MOD_PREFS';
     $pref_module['MOD_PREFS']->nom = CopixI18N::get('prefs|prefs.string.generalprefs');
     $pref_module['MOD_PREFS']->rep = 'prefs';
     $all_modules = array_merge($pref_module, $my_modules);
     return $all_modules;
 }
 /**
  * Récupération de tous les agendas en base de données
  * @author Audrey Vassal <*****@*****.**>
  * @since 2006/07/24
  * @return array tableau d'objet agenda
  */
 public function getAvailableAgenda()
 {
     //var_dump($_SESSION);
     if (!_sessionGet('modules|agenda|his')) {
         $serviceAuth = new AgendaAuth();
         $res = array();
         $ags = array();
         // 1. Son agenda perso
         $userInfo = Kernel::getUserInfo();
         // Création des modules inexistants.
         Kernel::createMissingModules($userInfo["type"], $userInfo["id"]);
         // Liste des modules activés.
         $modsList = Kernel::getModEnabled($userInfo["type"], $userInfo["id"]);
         foreach ($modsList as $modInfo) {
             if ($modInfo->module_type == "MOD_AGENDA" && $modInfo->module_id) {
                 $ags[] = $modInfo->module_id;
             }
         }
         // 2. Ceux de sa classe, son école, ses groupes...
         $mynodes = Kernel::getNodes();
         foreach ($mynodes as $nodes) {
             foreach ($nodes as $node) {
                 //print_r($node);
                 if (substr($node['type'], 0, 5) == 'USER_') {
                     continue;
                 }
                 $modules = Kernel::getModEnabled($node['type'], $node['id']);
                 $agenda = Kernel::filterModuleList($modules, 'MOD_AGENDA');
                 if ($agenda && $serviceAuth->getCapability($agenda[0]->module_id) >= $serviceAuth->getRead()) {
                     $ags[] = $agenda[0]->module_id;
                 }
             }
         }
         //print_r($ags);
         $daoAgenda =& CopixDAOFactory::getInstanceOf('agenda|agenda');
         $agendas = $daoAgenda->findAgendasInIds($ags);
         foreach ($agendas as $agenda) {
             $tmp = new stdClass();
             $tmp->id_agenda = $agenda->id_agenda;
             $tmp->title_agenda = $agenda->title_agenda;
             $tmp->desc_agenda = $agenda->desc_agenda;
             $tmp->type_agenda = $agenda->type_agenda;
             /*
                       $tmp = array (
                           'id_agenda' => $agenda->id_agenda,
                           'title_agenda' => $agenda->title_agenda,
                           'desc_agenda' => $agenda->desc_agenda,
                           'type_agenda' => $agenda->type_agenda,
                       );
             */
             $res[] = $tmp;
         }
         //die();
         //$sess = $daoAgenda->findAll ();
         _sessionSet('modules|agenda|his', serialize($res));
     }
     return unserialize(_sessionGet('modules|agenda|his'));
 }
 public function _createContent(&$toReturn)
 {
     $ppo = new CopixPPO();
     // Récupération des paramètres
     $ppo->classeurId = $this->getParam('classeurId');
     $ppo->dossierCourant = $this->getParam('dossierCourant');
     // Paramètres pour la vue popup
     $ppo->field = $this->getParam('field');
     $ppo->format = $this->getParam('format');
     $ppo->withPersonal = _sessionGet('user_animateur') ? false : $this->getParam('withPersonal', true);
     $ppo->moduleType = $this->getParam('moduleType', null);
     $ppo->moduleId = $this->getParam('moduleId', null);
     // Récupération des classeurs accessibles à l'utilisateur
     $classeurIds = array();
     // Récupération de ses ressources (obligatoire pour récupérer le classeur personnel)
     $nodes = Kernel::getMyNodes(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
     foreach ($nodes as $node) {
         $modules = Kernel::getModEnabled($node->type, $node->id, _currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
         foreach ($modules as $module) {
             if ($module->module_type == 'MOD_CLASSEUR' && Kernel::getLevel('MOD_CLASSEUR', $module->module_id) >= PROFILE_CCV_READ) {
                 // Le module correspond-il au classeur personnel
                 if ($ppo->withPersonal && strpos($module->node_type, 'USER_') !== false && ($module->node_type == _currentUser()->getExtra('type') && $module->node_id == _currentUser()->getExtra('id'))) {
                     $ppo->classeurPersonnel = $module->module_id;
                     $classeurIds[] = $module->module_id;
                 } elseif (null === $ppo->moduleType) {
                     $classeurIds[] = $module->module_id;
                 }
             }
         }
     }
     // Récupération des ressources
     if (null !== $ppo->moduleType) {
         $node = Kernel::getModParentInfo($ppo->moduleType, $ppo->moduleId);
         $modules = Kernel::getModEnabled($node['type'], $node['id'], _currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
         foreach ($modules as $module) {
             if ($module->module_type == 'MOD_CLASSEUR' && Kernel::getLevel('MOD_CLASSEUR', $module->module_id) >= PROFILE_CCV_READ) {
                 $classeurIds[] = $module->module_id;
             }
         }
     }
     // Dédoublonnage des classeurs (responsables avec plusieurs enfants)
     $classeurIds = array_unique($classeurIds);
     $ppo->classeurs = array();
     $classeurDAO = _dao("classeur|classeur");
     foreach ($classeurIds as $classeurId) {
         $classeur = $classeurDAO->get($classeurId);
         $classeur->titre = $classeur->realName();
         $ppo->classeurs[] = $classeur;
     }
     _classInclude('classeurservice');
     $ppo->classeursOuverts = ClasseurService::getClasseursTreeState();
     if (!is_array($ppo->classeursOuverts)) {
         $ppo->classeursOuverts = array();
     }
     $this->flash->addCycle();
     $toReturn = $this->_usePPO($ppo, '_arborescence_classeurs.tpl');
 }
 /**
  * Retourne l'ID du classeur personnel
  *
  * @return int ou false si classeur perso non récupéré
  */
 public static function getClasseurPersonnelId()
 {
     $nodes = Kernel::getMyNodes(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
     foreach ($nodes as $node) {
         $modules = Kernel::getModEnabled($node->type, $node->id, _currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
         foreach ($modules as $module) {
             if ($module->module_type == "MOD_CLASSEUR") {
                 // Identification du classeur personnel de l'utilisateur
                 if (strpos($module->node_type, 'USER_') !== false && ($module->node_type == _currentUser()->getExtra('type') && $module->node_id == _currentUser()->getExtra('id'))) {
                     return $module->module_id;
                 }
             }
         }
     }
     return false;
 }
 public function _createContent(&$toReturn)
 {
     $ppo = new CopixPPO();
     // Récupération des paramètres
     $ppo->classeurId = $this->getParam('classeurId');
     $ppo->targetType = $this->getParam('targetType');
     $ppo->targetId = $this->getParam('targetId');
     $ppo->withMainLocker = $this->getParam('withMainLocker', true);
     $ppo->withSubLockers = $this->getParam('withSubLockers', Kernel::getLevel('MOD_CLASSEUR', $ppo->classeurId) >= PROFILE_CCV_PUBLISH ? true : false);
     // Récupération des classeurs accessibles à l'utilisateur pour les actions de masse (copie / déplacement)
     $classeurIds = array();
     $nodes = Kernel::getMyNodes(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
     foreach ($nodes as $node) {
         $modules = Kernel::getModEnabled($node->type, $node->id, _currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
         foreach ($modules as $module) {
             if ($module->module_type == "MOD_CLASSEUR") {
                 // Identification du classeur personnel de l'utilisateur
                 if (strpos($module->node_type, 'USER_') !== false && ($module->node_type == _currentUser()->getExtra('type') && $module->node_id == _currentUser()->getExtra('id'))) {
                     $ppo->classeurPersonnel = $module->module_id;
                     $classeurIds[] = $module->module_id;
                 } elseif (strpos($module->node_type, 'USER_') == false && Kernel::getLevel('MOD_CLASSEUR', $module->module_id) >= PROFILE_CCV_MEMBER) {
                     $classeurIds[] = $module->module_id;
                 }
             }
         }
     }
     // Dédoublonnage des classeurs (responsables avec plusieurs enfants)
     $classeurIds = array_unique($classeurIds);
     $ppo->classeurs = array();
     $classeurDAO = _dao("classeur|classeur");
     foreach ($classeurIds as $classeurId) {
         $classeur = $classeurDAO->get($classeurId);
         $ppo->classeurs[] = $classeur;
     }
     _classInclude('classeurservice');
     $ppo->classeursOuverts = ClasseurService::getClasseursTreeState();
     if (!is_array($ppo->classeursOuverts)) {
         $ppo->classeursOuverts = array();
     }
     $toReturn = $this->_usePPO($ppo, '_selection_classeurs.tpl');
 }
 public function processAdmin()
 {
     //check if the user is admin :
     if (!Kernel::isAdmin()) {
         return $this->error('charte.noRight', true, '||');
     }
     $ppo = new CopixPPO();
     $ppo->errors = isset($this->flash->errors) ? $this->flash->errors : null;
     $ppo->success = isset($this->flash->success) ? $this->flash->success : null;
     $ppo->chartes = $this->service('CharteService')->getChartesTypes();
     $ppo->radio = array(1 => 'oui', 0 => 'non');
     $ppo->idClasseur = $ppo->idMalle = null;
     $modsAvailable = Kernel::getModAvailable($this->user->type);
     $malleAvailable = Kernel::filterModuleList($modsAvailable, 'MOD_MALLE');
     // Malle activée
     if (!empty($malleAvailable)) {
         $modsEnabled = Kernel::getModEnabled($this->user->type, $this->user->idEn);
         $mal = Kernel::filterModuleList($modsEnabled, 'MOD_MALLE');
         // Si la malle est bien initialisée
         if (!empty($mal)) {
             $ppo->idMalle = $mal[0]->module_id;
         } else {
             return $this->error('charte.admin.noMalle', true, 'malle||');
         }
     } else {
         $classeurAvailable = Kernel::filterModuleList($modsAvailable, 'MOD_CLASSEUR');
         // Classeur activé
         if (!empty($classeurAvailable)) {
             Kernel::createMissingModules($this->user->type, $this->user->idEn);
             $modsEnabled = Kernel::getModEnabled($this->user->type, $this->user->idEn);
             $classeur = Kernel::filterModuleList($modsEnabled, 'MOD_CLASSEUR');
             if (!empty($classeur)) {
                 $ppo->idClasseur = $classeur[0]->module_id;
             }
         }
     }
     CopixHTMLHeader::addCSSLink(_resource("styles/module_charte.css"));
     return _arPPO($ppo, 'charte.admin.tpl');
 }
 public function _createContent(&$toReturn)
 {
     //Getting the user.
     //Create Services, and DAO
     $tpl = new CopixTpl();
     $id_blog = $this->getParam('id_blog', '');
     //capability
     //$tpl->assign ('canManageDocument' , BlogAuth::canMakeInBlog('ADMIN_DOCUMENTS',create_blog_object($id_blog)));
     // On regarde si le parent a un album photos
     $parent = Kernel::getModParentInfo("MOD_BLOG", $id_blog);
     //print_r($parent);
     if ($parent) {
         $mods = Kernel::getModEnabled($parent['type'], $parent['id']);
         $mods = Kernel::filterModuleList($mods, 'MOD_MALLE');
         if ($mods) {
             $tpl->assign('album', $mods[0]->module_id);
         }
     }
     $tpl->assign('id_blog', $id_blog);
     $tpl->assign('kind', $this->getParam('kind', ''));
     // retour de la fonction :
     $toReturn = $tpl->fetch('blog.show.document.tpl');
     return true;
 }
/**
 * Retourne le blog d'un noeud (personne, �cole, classe...)
 *
 * @author Christophe Beyer <*****@*****.**>
 * @since 2006/05/16
 * @param string $parent_type Type du parent (club, classe...)
 * @param string $parent_id Id du parent
 * @param array $pOptions Options [is_public] pour forcer un test sur le champ is_public
 * @return mixed NULL si pas de blog, le recordset sinon
 */
function getNodeBlog($parent_type, $parent_id, $options = array())
{
    $blog = NULL;
    $trouve = false;
    $hisModules = Kernel::getModEnabled($parent_type, $parent_id);
    foreach ($hisModules as $node) {
        //print_r($node);
        if ($trouve) {
            break;
        }
        if ($node->module_type == 'MOD_BLOG') {
            $dao = _dao("blog|blog");
            $blog = $dao->get($node->module_id);
            if (isset($options['is_public']) && $blog->is_public != $options['is_public']) {
                $blog = null;
            }
            $trouve = true;
        }
    }
    //remove empty blog
    if (!empty($blog)) {
        $result = _doQuery('SELECT COUNT(*) AS count FROM module_blog_article WHERE id_blog = :id AND is_online = 1', array(':id' => $blog->id_blog));
        if ($result[0]->count == 0) {
            $blog = null;
        }
    }
    return $blog;
}
 /**
  * Afficage de la liste des articles d'un blog.
  */
 public function processGetListArticle()
 {
     //var_dump($this);
     if (!_request('blog') && !_request('ecole')) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.missingParameters'), 'back' => CopixUrl::get('||')));
     }
     //On verifie que le blog existe (on r�cup�re le blog avec son nom )
     if (_request('blog')) {
         $dao = CopixDAOFactory::create('blog|blog');
         if (!($blog = $dao->getBlogByName(_request('blog')))) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.unableToFindBlog'), 'back' => CopixUrl::get('||')));
         }
     }
     //On verifie que le blog existe (on r�cup�re le blog l'id de l'�cole )
     if (CopixRequest::getInt('ecole')) {
         $blog = false;
         $mod = Kernel::getModEnabled('BU_ECOLE', CopixRequest::getInt('ecole'), 'MOD_BLOG');
         if ($mod) {
             $mod = Kernel::filterModuleList($mod, 'MOD_BLOG');
             if ($mod) {
                 if ($blog = _ioDAO('blog|blog')->getBlogById($mod[0]->module_id)) {
                     //print_r($blog);
                 }
             }
         }
         if (!$blog) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.unableToFindBlog'), 'back' => CopixUrl::get('||')));
         }
     }
     // On v�rifie que le droit de lecture est pr�sent
     if (!BlogAuth::canMakeInBlog('READ', $blog)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get('||')));
     }
     //si la cat�gorie est fournie on v�rifie qu'elle existe
     if (null != ($cat = $this->getRequest('cat', null))) {
         $daoCat = CopixDAOFactory::create('blog|blogarticlecategory');
         if (!($cat = $daoCat->getCategoryByName($blog->id_blog, $cat))) {
             return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.unableToFindCat'), 'back' => CopixUrl::get('blog||', array('blog' => _request('blog')))));
         }
     }
     //		$menu = array();
     $parent = Kernel::getModParentInfo("MOD_BLOG", $blog->id_blog);
     $blog->parent = $parent;
     /*		if ($parent['type']=='CLUB') {
                 $droit = Kernel::getLevel($parent['type'], $parent['id']);
                 if (GroupeService::canMakeInGroupe('VIEW_HOME', $droit))
                     $menu[] = array('url'=>CopixUrl::get ('groupe||getHome', array("id"=>$parent['id'])), 'txt'=>CopixI18N::get ('blog.menuToGroup'));
             }
             if (BlogAuth::canMakeInBlog('ACCESS_ADMIN',$blog))
                 $menu[] = array('url'=>CopixUrl::get ('admin|showBlog', array("id_blog"=>$blog->id_blog)), 'txt'=>CopixI18N::get ('blog.menuAdmin'));
     */
     $menu = array();
     if (BlogAuth::canMakeInBlog('ACCESS_ADMIN', $blog)) {
         $menu = getBlogAdminMenu($blog);
     }
     CopixHTMLHeader::addCSSLink(CopixUrl::get('blog||getBlogCss', array('id_blog' => $blog->id_blog)));
     $tpl = new CopixTpl();
     $tpl->assign('TITLE_PAGE', $blog->name_blog);
     $tpl->assign('blog', $blog);
     $tpl->assign('MENU', $menu);
     $tpl->assign('ListArticle', CopixZone::process('ListArticle', array('blog' => $blog, 'cat' => $cat, 'date' => $this->getRequest('date', null), 'critere' => $this->getRequest('critere', null))));
     $tpl->assign('ListLink', CopixZone::process('ListLink', array('blog' => $blog)));
     $tpl->assign('ListCategory', CopixZone::process('ListCategory', array('blog' => $blog)));
     $tpl->assign('ListArchive', CopixZone::process('ListArchive', array('blog' => $blog)));
     $tpl->assign('ListPage', CopixZone::process('ListPage', array('blog' => $blog)));
     $tpl->assign('ListSearch', CopixZone::process('ListSearch', array('blog' => $blog)));
     $tpl->assign('ListFluxRss', CopixZone::process('ListFluxRss', array('blog' => $blog)));
     CopixHtmlHeader::addOthers('<link rel="alternate" href="' . CopixUrl::get('blog||rss', array("blog" => $blog->url_blog)) . '" type="application/rss+xml" title="' . htmlentities($blog->name_blog) . '" />');
     if ($blog->template) {
         $MAIN = $tpl->fetch($blog->template);
     } else {
         $MAIN = $tpl->fetch('blog_main.tpl');
     }
     $tpl->assign('MAIN', $MAIN);
     $tpl->assign('HEADER_MODE', 'compact');
     $plugStats = CopixPluginRegistry::get("stats|stats");
     $plugStats->setParams(array('module_id' => $blog->id_blog, 'parent_type' => $parent['type'], 'parent_id' => $parent['id']));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }
 /**
  * Renvoie le blog d'un groupe
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/03/09
  * @param integer $groupe	Id du groupe
  * @return mixed NULL si pas de blog, le recordset sinon
  */
 public function getGroupeBlog($groupe)
 {
     $blog = NULL;
     $hisModules = Kernel::getModEnabled("club", $groupe);
     foreach ($hisModules as $node) {
         //print_r($node);
         if ($node->module_type == 'MOD_BLOG') {
             $dao = _dao("blog|blog");
             $blog = $dao->get($node->module_id);
         }
     }
     return $blog;
 }
 /**
  * Verifie si le blog des teleprocedures d'une ville existe. Si non, le cree. Renvoie son id.
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2009/01/23
  * @param object $rTelep Recordset de la teleprocedure
  * @return object Recordset du blog
  */
 public function checkIfBlogExists($rTelep)
 {
     $modEnabled = Kernel::getModEnabled('MOD_TELEPROCEDURES', $rTelep->id);
     $return = null;
     $exists = false;
     foreach ($modEnabled as $mod) {
         if ($mod->module_type == 'MOD_BLOG') {
             $exists = $mod->module_id;
         }
     }
     if (!$exists) {
         // Il faut creer le blog
         $modname = 'blog';
         $file =& CopixSelectorFactory::create($modname . "|" . $modname);
         $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php';
         if (is_readable($filePath)) {
             $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname);
             if (method_exists($modservice, "create")) {
                 $title = $rTelep->titre . ' - ' . CopixI18N::get('teleprocedures|teleprocedures.moduleDescription');
                 $modid = $modservice->create(array('title' => $title, 'is_public' => 0));
                 if ($modid != null) {
                     Kernel::registerModule('MOD_BLOG', $modid, 'MOD_TELEPROCEDURES', $rTelep->id);
                     // Si le blog est cree, on cree aussi la malle et l'album
                     $modname = 'album';
                     $file =& CopixSelectorFactory::create($modname . "|" . $modname);
                     $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php';
                     if (is_readable($filePath)) {
                         $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname);
                         if (method_exists($modservice, "create")) {
                             $title = $rTelep->titre . ' - ' . CopixI18N::get('teleprocedures|teleprocedures.moduleDescription');
                             $mod2id = $modservice->create(array('title' => $title));
                             if ($mod2id != null) {
                                 Kernel::registerModule('MOD_ALBUM', $mod2id, 'MOD_TELEPROCEDURES', $rTelep->id);
                             }
                         }
                     }
                     $modname = 'malle';
                     $file =& CopixSelectorFactory::create($modname . "|" . $modname);
                     $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php';
                     if (is_readable($filePath)) {
                         $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname);
                         if (method_exists($modservice, "create")) {
                             $title = $rTelep->titre . ' - ' . CopixI18N::get('teleprocedures|teleprocedures.moduleDescription');
                             $mod2id = $modservice->create(array('title' => $title));
                             if ($mod2id != null) {
                                 Kernel::registerModule('MOD_MALLE', $mod2id, 'MOD_TELEPROCEDURES', $rTelep->id);
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $modid = $exists;
     }
     if ($modid) {
         $daoBlog =& _dao('blog|blog');
         $return = $daoBlog->get($modid);
     }
     return $return;
 }
 /**
  * Edition d'un mémo - * Enseignant *
  */
 public function processEditerMemo()
 {
     $ppo = new CopixPPO();
     if (is_null($ppo->cahierId = _request('cahierId', null))) {
         return CopixActionGroup::process('generictools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.errorOccurred'), 'back' => CopixUrl::get('')));
     } elseif (Kernel::getLevel('MOD_CAHIERDETEXTES', $ppo->cahierId) < PROFILE_CCV_PUBLISH) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('kernel|kernel.error.noRights'), 'back' => CopixUrl::get('')));
     }
     // Récupération des paramètres
     $ppo->jour = _request('jour', date('d'));
     $ppo->mois = _request('mois', date('m'));
     $ppo->annee = _request('annee', date('Y'));
     $ppo->msgSuccess = _request('msgSuccess', false);
     $ppo->dateSelectionnee = mktime(0, 0, 0, $ppo->mois, $ppo->jour, $ppo->annee);
     $ppo->format = CopixConfig::get('cahierdetextes|format_par_defaut');
     $cahierInfos = Kernel::getModParent('MOD_CAHIERDETEXTES', $ppo->cahierId);
     $ppo->nodeInfos = array('type' => $cahierInfos[0]->module_type, 'id' => $cahierInfos[0]->module_id);
     if (is_null($memoId = _request('memoId', null))) {
         $ppo->memo = _record('cahierdetextes|cahierdetextesmemo');
     } else {
         $memoDAO = _ioDAO('cahierdetextes|cahierdetextesmemo');
         $ppo->memo = $memoDAO->get($memoId);
         $ppo->memo->date_creation = CopixDateTime::yyyymmddToDate($ppo->memo->date_creation);
         $ppo->memo->date_validite = CopixDateTime::yyyymmddToDate($ppo->memo->date_validite);
         $ppo->memo->date_max_signature = CopixDateTime::yyyymmddToDate($ppo->memo->date_max_signature);
         // Récupération des élèves liés au mémo
         $memo2eleveDAO = _ioDAO('cahierdetextes|cahierdetextesmemo2eleve');
         $ppo->elevesSelectionnes = $memo2eleveDAO->findElevesParMemo($ppo->memo->id);
         // Récupération des fichiers liés au mémo
         $fichierMalleDAO = _ioDAO('malle|malle_files');
         $fichierClasseurDAO = _ioDAO('classeur|classeurfichier');
         $memo2fichiersDAO = _ioDAO('cahierdetextes|cahierdetextesmemo2files');
         $memo2fichiers = $memo2fichiersDAO->retrieveByMemo($ppo->memo->id);
         $ppo->fichiers = array();
         $fichiers = array();
         foreach ($memo2fichiers as $memo2fichier) {
             if ($memo2fichier->module_file == 'MOD_MALLE') {
                 if ($fichier = $fichierMalleDAO->get($memo2fichier->file_id)) {
                     $ppo->fichiers[] = array('type' => $memo2fichier->module_file, 'id' => $memo2fichier->file_id, 'nom' => $fichier->nom);
                 }
             } elseif ($memo2fichier->module_file == 'MOD_CLASSEUR') {
                 if ($fichier = $fichierClasseurDAO->get($memo2fichier->file_id)) {
                     $ppo->fichiers[] = array('type' => $memo2fichier->module_file, 'id' => $memo2fichier->file_id, 'nom' => $fichier);
                 }
             }
         }
     }
     if (CopixRequest::isMethod('post')) {
         $cahierInfos = Kernel::getModParent('MOD_CAHIERDETEXTES', $ppo->cahierId);
         $ppo->memo->classe_id = $cahierInfos[0]->node_id;
         $ppo->memo->date_creation = CopixDateTime::dateToyyyymmdd(_request('memo_date_creation', null));
         $ppo->memo->date_validite = CopixDateTime::dateToyyyymmdd(_request('memo_date_validite', null));
         $ppo->memo->message = _request('memo_message', null);
         $ppo->memo->avec_signature = _request('memo_avec_signature', 0);
         $ppo->memo->date_max_signature = CopixDateTime::dateToyyyymmdd(_request('memo_date_max_signature', null));
         $ppo->memo->supprime = 0;
         $ppo->elevesSelectionnes = _request('eleves', array());
         $ppo->fichiers = _request('memo_fichiers', array());
         // Traitement des erreurs
         $ppo->erreurs = array();
         if ($ppo->memo->date_creation == '') {
             $ppo->erreurs[] = CopixI18N::get('cahierdetextes|cahierdetextes.error.noCreationDate');
         }
         if ($ppo->memo->date_validite == '') {
             $ppo->erreurs[] = CopixI18N::get('cahierdetextes|cahierdetextes.error.noValidityDate');
         }
         if (!is_null($ppo->memo->date_validite) && $ppo->memo->date_validite < $ppo->memo->date_creation) {
             $ppo->erreurs[] = CopixI18N::get('cahierdetextes|cahierdetextes.error.wrongValidityDate');
         }
         if ($ppo->memo->message == '') {
             $ppo->erreurs[] = CopixI18N::get('cahierdetextes|cahierdetextes.error.noContent');
         }
         if ($ppo->memo->avec_signature && $ppo->memo->date_max_signature == '') {
             $ppo->erreurs[] = CopixI18N::get('cahierdetextes|cahierdetextes.error.noSignatureDate');
         }
         if (!is_null($ppo->memo->date_max_signature) && !is_null($ppo->memo->date_validite) && ($ppo->memo->date_max_signature > $ppo->memo->date_validite || $ppo->memo->date_max_signature < $ppo->memo->date_creation)) {
             $ppo->erreurs[] = CopixI18N::get('cahierdetextes|cahierdetextes.error.wrongMaxSignatureDate');
         }
         if (empty($ppo->elevesSelectionnes)) {
             $ppo->erreurs[] = CopixI18N::get('cahierdetextes|cahierdetextes.error.noStudents');
         }
         if (!empty($ppo->fichiers)) {
             $ppo->fichiers = array_unique($ppo->fichiers);
             // Récupération de l'identifiant de la malle du node
             $mods = Kernel::getModEnabled($cahierInfos[0]->node_type, $cahierInfos[0]->node_id);
             if ($malle = Kernel::filterModuleList($mods, 'MOD_MALLE')) {
                 $malleId = $malle[0]->module_id;
             }
             // Récupération des identifiants de classeur
             $classeurIds = array();
             // Classeur du node
             $mods = Kernel::getModEnabled($cahierInfos[0]->node_type, $cahierInfos[0]->node_id);
             if ($classeur = Kernel::filterModuleList($mods, 'MOD_CLASSEUR')) {
                 $classeurIds[] = $classeur[0]->module_id;
             }
             // Classeur personnel
             $mods = Kernel::getModEnabled(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
             if ($classeur = Kernel::filterModuleList($mods, 'MOD_CLASSEUR')) {
                 $classeurIds[] = $classeur[0]->module_id;
             }
             // On détermine s'il s'agit de documents de la malle ou du classeur
             foreach ($ppo->fichiers as $fichierInfos) {
                 $fichierInfos = explode('-', $fichierInfos);
                 if ($fichierInfos[0] == 'MOD_MALLE') {
                     // Erreur : le fichier n'appartient pas à la malle du node
                     if (!$fichierMalleDAO->isFileOfMalle($fichierInfos[1], $malleId)) {
                         $ppo->erreurs[] = CopixI18N::get('cahierdetextes|cahierdetextes.error.invalidFile');
                         break;
                     } else {
                         $fichier = $fichierMalleDAO->get($fichierInfos[1]);
                         $fichiers[] = array('type' => $fichierInfos[0], 'id' => $fichierInfos[1], 'nom' => $fichier->nom);
                     }
                 } elseif ($fichierInfos[0] == 'MOD_CLASSEUR') {
                     $fichier = $fichierClasseurDAO->get($fichierInfos[1]);
                     // Erreur : le fichier n'appartient pas aux classeurs disponible à l'utilisateur
                     if (!in_array($fichier->classeur_id, $classeurIds)) {
                         $ppo->erreurs[] = CopixI18N::get('cahierdetextes|cahierdetextes.error.invalidFile');
                         break;
                     } else {
                         $fichiers[] = array('type' => $fichierInfos[0], 'id' => $fichierInfos[1], 'nom' => $fichier);
                     }
                 }
             }
         }
         if (!empty($ppo->erreurs)) {
             $ppo->memo->date_creation = _request('memo_date_creation', null);
             $ppo->memo->date_validite = _request('memo_date_validite', null);
             $ppo->memo->date_max_signature = _request('memo_date_max_signature', null);
             if (isset($fichiers)) {
                 $ppo->fichiers = $fichiers;
             }
             $modParentInfo = Kernel::getModParentInfo('MOD_CAHIERDETEXTES', $ppo->cahierId);
             $ppo->TITLE_PAGE = $modParentInfo['nom'];
             return _arPPO($ppo, 'editer_memo.tpl');
         }
         $memoDAO = _ioDAO('cahierdetextes|cahierdetextesmemo');
         $memo2eleveDAO = _ioDAO('cahierdetextes|cahierdetextesmemo2eleve');
         $memo2fichierDAO = _ioDAO('cahierdetextes|cahierdetextesmemo2files');
         // Création
         if ($ppo->memo->id == '') {
             // Insertion de l'enregistrement "memo"
             $memoDAO->insert($ppo->memo);
         } else {
             // Mise à jour de l'enregistrement "memo"
             $memoDAO->update($ppo->memo);
             // Suppression des relations memo - eleves existantes
             $memo2eleveDAO->deleteByMemo($ppo->memo->id);
             // Suppression des relations memo - fichiers existantes
             $memo2fichierDAO->deleteByMemo($ppo->memo->id);
         }
         // Insertion des nouveaux liens memo > eleve
         foreach ($ppo->elevesSelectionnes as $eleveId) {
             $memo2eleve = _record('cahierdetextes|cahierdetextesmemo2eleve');
             $memo2eleve->memo_id = $ppo->memo->id;
             $memo2eleve->eleve_id = $eleveId;
             $memo2eleveDAO->insert($memo2eleve);
         }
         // Insertion des liens "mémo > fichiers"
         if (!empty($fichiers)) {
             foreach ($fichiers as $fichier) {
                 $memo2fichier = _record('cahierdetextes|cahierdetextesmemo2files');
                 $memo2fichier->memo_id = $ppo->memo->id;
                 $memo2fichier->module_file = $fichier['type'];
                 $memo2fichier->file_id = $fichier['id'];
                 $memo2fichierDAO->insert($memo2fichier);
             }
         }
         return _arRedirect(CopixUrl::get('cahierdetextes||voirMemos', array('cahierId' => $ppo->cahierId, 'msgSuccess' => CopixI18N::get('cahierdetextes|cahierdetextes.message.success'))));
     }
     $modParentInfo = Kernel::getModParentInfo('MOD_CAHIERDETEXTES', $ppo->cahierId);
     $ppo->TITLE_PAGE = $modParentInfo['nom'];
     return _arPPO($ppo, 'editer_memo.tpl');
 }
 /**
  * Entrée générique dans un agenda
  * @author Christophe Beyer <*****@*****.**>
  * @since 2006/08/24
  * @param integer $id Id de l'agenda (si aucun, l'envoie dans l'agenda perso)
  */
 public function go()
 {
     $id = $this->getRequest('id', null);
     $dao = CopixDAOFactory::create('agenda|agenda');
     if ($id == null) {
         // Si pas d'id, on l'envoie dans son agenda perso
         $userInfo = Kernel::getUserInfo();
         // Création des modules inexistants.
         Kernel::createMissingModules($userInfo["type"], $userInfo["id"]);
         // Liste des modules activés.
         $modsList = Kernel::getModEnabled($userInfo["type"], $userInfo["id"]);
         foreach ($modsList as $modInfo) {
             if ($modInfo->module_type == "MOD_AGENDA" && $modInfo->module_id) {
                 $id = $modInfo->module_id;
             }
         }
     }
     if ($id && ($agenda = $dao->get($id))) {
         $this->_setSessionSemaineParams(null);
         $obj = new AgendaService();
         $obj->setAgendaAffiches(array($id => $id));
         return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('agenda|agenda|'));
     }
     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
 }
 /**
  * Acces direct a un module
  *
  * Fonction generique d'acces a un module depuis un noeud.
  *
  * @author Stephane Holtz <*****@*****.**>
  */
 public function go()
 {
     // NOTIFICATIONS : Préparation de l'enregistrement de la visite. Le module_id est à completer avant enregistrement.
     $lastvisit = _record("kernel|kernel_notifications_lastvisit");
     $lastvisit->user_id = $this->user->id;
     // id Copix
     $lastvisit->date = date('Y-m-d H:i:s');
     $lastvisit->node_type = _request("ntype");
     $lastvisit->node_id = _request("nid");
     $lastvisit->module_type = _request("mtype");
     $lastvisit->module_id = null;
     $mid = _request("mid", 0);
     if (!is_null(_request("ntype")) && !is_null(_request("nid")) && !is_null(_request("mtype"))) {
         CopixSession::set('myNode', array('type' => _request("ntype"), 'id' => _request("nid")));
         if (_request("ntype") == 'CLUB' && _request("mtype") == 'comptes' && !_request("mid")) {
             $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('groupe||getHomeMembers', array('id' => _request("nid"))));
         } elseif (_request("ntype") == 'CLUB' && _request("mtype") == 'admin' && !_request("mid")) {
             $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('groupe||getHomeAdmin', array('id' => _request("nid"))));
         } elseif (strpos(_request("ntype"), 'USER_') === false) {
             // Si on ne connait pas l'ID du module, on tente de le detecter automatiquement
             if (!$mid) {
                 $modules = Kernel::getModEnabled(_request("ntype"), _request("nid"), '', 0, 0, true);
                 foreach ($modules as $module) {
                     if ($module->module_type == 'MOD_' . strtoupper(_request("mtype"))) {
                         if (isset($module->module_id)) {
                             $mid = $module->module_id;
                         } else {
                             $mid = 0;
                         }
                         break;
                     }
                 }
             }
             // die('CopixUrl::get('._request("mtype").'|default|go   id='.$mid);
             $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get(_request("mtype") . '|default|go', array('id' => $mid)));
         } else {
             if ($mid) {
                 $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get(_request("mtype") . '|default|go', array('id' => $mid)));
             } else {
                 $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get(_request("mtype") . '||'));
             }
         }
         // NOTIFICATIONS : Enregistrement de la visite de l'utilisateur (avec suppression de doublons)
         if ($mid) {
             $lastvisit->module_id = $mid;
         }
         if ($lastvisit->user_id) {
             _dao('kernel|kernel_notifications_lastvisit')->deleteBy(_daoSp()->addCondition('user_id', '=', $lastvisit->user_id)->addCondition('node_type', '=', $lastvisit->node_type)->addCondition('node_id', '=', $lastvisit->node_id)->addCondition('module_type', '=', $lastvisit->module_type)->addCondition('module_id', '=', $lastvisit->module_id));
             _dao("kernel|kernel_notifications_lastvisit")->insert($lastvisit);
         }
         // LOGS : Logs d'usage
         Logs::set(array('type' => 'GO', 'node_type' => _request("ntype"), 'node_id' => _request("nid"), 'module_type' => _request("mtype"), 'module_id' => $mid ? $mid : null));
         return $loadModule;
     }
     $loadModule = new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('||'));
     return $loadModule;
 }
 /**
  * Publication automatique par mail
  *
  * @author Frederic Mossmann <*****@*****.**>
  * @since 2006/07/28
  */
 public function doMailPublish()
 {
     if (_request("key")) {
         if (ereg("^([0-9]{8}-[0-9]{6})-([a-zA-Z0-9]+)-([a-fA-F0-9]{32})\$", _request("key"), $regs)) {
             $key = _request("key");
             $login = $regs[2];
             $dao = CopixDAOFactory::create("magicmail|magicmail");
             $mymagicmail = $dao->getByLogin($login);
             $error = false;
             if (sizeof($mymagicmail)) {
                 $nodes = Kernel::getModParent("MOD_MAGICMAIL", $mymagicmail[0]->magicmail_id);
                 if (sizeof($nodes)) {
                     $node_type = $nodes[0]->node_type;
                     $node_id = $nodes[0]->node_id;
                 } else {
                     $error = true;
                 }
             } else {
                 $error = true;
             }
             if (!$error) {
                 $file = @fopen(CopixConfig::get('magicmail|magicmail_url') . 'data/' . $key . '/' . 'info.txt', 'r');
                 if ($file) {
                     $reply = '';
                     while (!feof($file)) {
                         $reply .= fgets($file, 4096);
                     }
                     // while (!feof($file))
                     fclose($file);
                     // <-- DEBUT TRAITEMENT -->
                     //////////////////////////
                     $blog_service =& CopixClassesFactory::Create('blog|kernelblog');
                     $album_classes =& CopixClassesFactory::Create('album|album');
                     $album_service =& CopixClassesFactory::Create('album|kernelalbum');
                     $classeur_service =& CopixClassesFactory::Create('classeur|kernelclasseur');
                     /*
                     $groupe_service = & CopixClassesFactory::Create ('groupe|groupeservice');
                     $blog = $groupe_service->getGroupeBlog( $grp );
                     $album = $groupe_service->getGroupeAlbum( $grp );
                     */
                     $blog = null;
                     $album = null;
                     $mods = Kernel::getModEnabled($node_type, $node_id);
                     foreach ($mods as $mod) {
                         switch ($mod->module_type) {
                             case 'MOD_CLASSEUR':
                                 $classeur = $mod->module_id;
                                 break;
                             case 'MOD_ALBUM':
                                 $album = $mod->module_id;
                                 break;
                             case 'MOD_BLOG':
                                 $blog = $mod->module_id;
                                 break;
                         }
                     }
                     /*
                     if( $blog == null ) {
                         echo "-ERR No Blog\n";
                         return new CopixActionReturn (COPIX_AR_NONE, 0);
                     }
                     if( $album == null ) {
                         echo "-ERR No Album\n";
                         return new CopixActionReturn (COPIX_AR_NONE, 0);
                     }
                     */
                     // echo "<br \>Blog: ".$blog." - Album: ".$album."<br \>\n";
                     //////////////////////////
                     $blog_article = array();
                     $album_photos = array();
                     $audio_files = array();
                     while (ereg("^(SUBJECT|IMAGE|AUDIO|VIDEO-FLV|BODY) ?([^\n]+)\n(.*)\$", $reply, $regs)) {
                         // echo "<li>".$regs[0]."<br/>\n<li>".$regs[1]."<br/>\n<li>".$regs[2]."<br/>\n<li>".$regs[3];
                         switch ($regs[1]) {
                             case 'SUBJECT':
                                 $blog_article['title'] = $regs[2];
                                 break;
                             case 'IMAGE':
                                 if (ereg("^([0-9a-fA-F]+) ([0-9]+) (.*)\$", $regs[2], $image_data)) {
                                     $photo_file = fopen(CopixConfig::get('magicmail|magicmail_url') . 'data/' . $key . '/' . $image_data[1], 'r');
                                     $photo_data = '';
                                     if ($file) {
                                         while (!feof($photo_file)) {
                                             $photo_data .= fgets($photo_file, 4096);
                                         }
                                         // while (!feof($file))
                                         fclose($photo_file);
                                     }
                                     $album_photos[] = array('file' => $image_data[3], 'title' => $image_data[3], 'data' => $photo_data);
                                 }
                                 break;
                             case 'AUDIO':
                                 if (ereg("^([0-9a-fA-F]+) ([0-9]+) (.*)\$", $regs[2], $audio_data)) {
                                     $audio_files[] = array('file' => CopixConfig::get('magicmail|magicmail_url') . 'data/' . $key . '/' . $audio_data[1], 'title' => $audio_data[3]);
                                 }
                                 break;
                             case 'VIDEO-FLV':
                                 if (ereg("^([0-9a-fA-F]+) ([0-9]+) (.*)\$", $regs[2], $video_flv_data)) {
                                     $video_flv_files[] = array('file' => CopixConfig::get('magicmail|magicmail_url') . 'data/' . $key . '/' . $video_flv_data[1], 'title' => $video_flv_data[3]);
                                 }
                                 break;
                             case 'BODY':
                                 $blog_article['body'] = $regs[3];
                                 break;
                         }
                         $reply = $regs[3];
                     }
                     //////////////////////////
                     $images = array();
                     if ($classeur != null) {
                         if ($album_photos) {
                             foreach ($album_photos as $album_photo) {
                                 $album_photo_retour = $classeur_service->publish($classeur, $album_photo);
                                 $images[] = $album_photo_retour;
                             }
                         }
                     } else {
                         if ($album != null) {
                             if ($album_photos) {
                                 foreach ($album_photos as $album_photo) {
                                     $album_photo_retour = $album_service->publish($album, $album_photo);
                                     $images[] = $album_photo_retour;
                                 }
                             }
                         }
                     }
                     if ($blog != null) {
                         if (!$blog_article['title'] || trim($blog_article['title']) == '') {
                             $date = date('d/m/Y \\� H\\hi');
                             $blog_article['title'] = 'Article du ' . $date;
                         }
                         if (isset($audio_files)) {
                             foreach ($audio_files as $audio_file) {
                                 $blog_article['body'] .= "\n" . '[[' . $audio_file['file'] . "|mp3]]\n";
                             }
                         }
                         if (isset($video_flv_files)) {
                             foreach ($video_flv_files as $video_flv_file) {
                                 $blog_article['body'] .= "\n" . '[[' . $video_flv_file['file'] . ".flv|flv]]\n";
                             }
                         }
                         if (isset($images)) {
                             foreach ($images as $image) {
                                 // TODO
                                 if ($classeur != null) {
                                     $blog_article['body'] .= "\n" . '[((' . CopixUrl::get() . 'static/classeur/' . $image['album_id'] . '-' . $image['album_key'] . '/' . $image['photo_id'] . '-' . $image['photo_key'] . '_240.' . $image['photo_ext'] . '|' . $image['title'] . '|))|' . CopixUrl::get() . 'static/classeur/' . $image['album_id'] . '-' . $image['album_key'] . '/' . $image['photo_id'] . '-' . $image['photo_key'] . '.' . $image['photo_ext'] . ']' . "\n";
                                 } else {
                                     $blog_article['body'] .= "\n" . '[((' . CopixUrl::get() . 'static/album/' . $image['album_id'] . '_' . $image['album_key'] . '/' . $image['photo_id'] . '_' . $image['photo_key'] . '_240.' . $image['photo_ext'] . '|' . $image['title'] . '|))|' . CopixUrl::get() . 'static/album/' . $image['album_id'] . '_' . $image['album_key'] . '/' . $image['photo_id'] . '_' . $image['photo_key'] . '.' . $image['photo_ext'] . ']' . "\n";
                                 }
                             }
                         }
                         $blog_retour = $blog_service->publish($blog, $blog_article);
                         print_r($blog_retour);
                     }
                     // <-- FIN TRAITEMENT -->
                     echo "+OK\n";
                     // print_r( $images );
                     // echo htmlentities($reply);
                 } else {
                     echo "-ERR No info (file not found)\n";
                 }
             } else {
                 echo "-ERR Bad key\n";
             }
         } else {
             echo "-ERR Bad key (ereg not match)\n";
         }
     } else {
         echo "-ERR Bad key (not set)\n";
     }
     return new CopixActionReturn(COPIX_AR_NONE, 0);
 }
 /**
  * Affiche la série de boutons permettant à l'utilisateur de mettre en forme simplement le texte qu'il saisit dans une zone de texte libre.
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/12/28
  * @param string $field Nom du champ dans le formulaire. Correspond à l'attribut "name" et "id" dans le template (les deux doivent être positionnés)
  * @param string $format Format de la zone de saisie (wiki, html, fckeditor...)
  * @param array $objet (option) Module dans lequel se trouve la barre wiki, dans un tableau indexé avec TYPE et ID (exemple: type=>MOD_BLOG, ID=>4). Si positionné, on va vérifier si le parent de cet objet a un album photos, une malle et un classeur, et si oui on affiche les liens vers l'album photos, la malle et le classeur en mode popup
  */
 public function _createContent(&$toReturn)
 {
     $tpl = new CopixTpl();
     $field = $this->getParam('field', NULL);
     $format = $this->getParam('format', NULL);
     $object = $this->getParam('object', NULL);
     $withAlbum = $this->getParam('withAlbum', true);
     CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/wikibuttons.js');
     if ($field && $format) {
         $buttonAlbum = $buttonMalle = $buttonClasseur = array();
         // Bouton album photos et malle
         $buttons = array();
         // Tableau avec les boutons
         switch ($format) {
             case "wiki":
                 CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/format_' . $format . '.js');
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.bold'), 'accesskey' => 'g', 'tabindex' => 10, 'link' => "javascript:bbstyle('','{$field}',0);");
                 // Gras
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.italic'), 'accesskey' => 'i', 'tabindex' => 11, 'link' => "javascript:bbstyle('','{$field}',2);");
                 // Italique
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.image'), 'accesskey' => 'm', 'tabindex' => 12, 'link' => "javascript:bblink('','{$field}',12);");
                 // Image
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.link'), 'accesskey' => 'l', 'tabindex' => 13, 'link' => "javascript:bblink('','{$field}',8);");
                 // Lien
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.hr'), 'accesskey' => 'h', 'tabindex' => 14, 'link' => "javascript:bbcar('','{$field}',4);");
                 // HR
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h1'), 'accesskey' => 'j', 'tabindex' => 15, 'link' => "javascript:bblink('','{$field}',20);");
                 // H1
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h2'), 'accesskey' => 'v', 'tabindex' => 16, 'link' => "javascript:bblink('','{$field}',22);");
                 // H2
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h3'), 'accesskey' => 'w', 'tabindex' => 17, 'link' => "javascript:bblink('','{$field}',24);");
                 // H3
                 break;
             case "dokuwiki":
                 CopixHtmlHeader::addJSLink(CopixUrl::get() . 'js/iconito/format_' . $format . '.js');
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.bold'), 'accesskey' => 'g', 'tabindex' => 10, 'link' => "javascript:bbstyle('','{$field}',0);", 'icon' => 'bold.png');
                 // Gras
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.italic'), 'accesskey' => 'i', 'tabindex' => 11, 'link' => "javascript:bbstyle('','{$field}',2);", 'icon' => 'italic.png');
                 // Italique
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.underline'), 'accesskey' => 's', 'tabindex' => 12, 'link' => "javascript:bbstyle('','{$field}',4);", 'icon' => 'underline.png');
                 // Souligne
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.image'), 'accesskey' => 'm', 'tabindex' => 12, 'link' => "javascript:bblink('','{$field}',12);", 'icon' => 'image.png');
                 // Image
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.link'), 'accesskey' => 'l', 'tabindex' => 13, 'link' => "javascript:bblink('','{$field}',8);", 'icon' => 'linkextern.png');
                 // Lien
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.email'), 'accesskey' => 'e', 'tabindex' => 13, 'link' => "javascript:bblink('','{$field}',10);", 'icon' => '../../tpl/default/images/mail_icon.gif');
                 // Email
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.hr'), 'accesskey' => 'h', 'tabindex' => 14, 'link' => "javascript:bbcar('','{$field}',4);", 'icon' => 'hr.png');
                 // HR
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h1'), 'accesskey' => 'j', 'tabindex' => 15, 'link' => "javascript:bblink('','{$field}',20);", 'icon' => 'h1.png');
                 // H1
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h2'), 'accesskey' => 'v', 'tabindex' => 16, 'link' => "javascript:bblink('','{$field}',22);", 'icon' => 'h2.png');
                 // H2
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.h3'), 'accesskey' => 'w', 'tabindex' => 17, 'link' => "javascript:bblink('','{$field}',24);", 'icon' => 'h3.png');
                 // H3
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.ul'), 'accesskey' => 'w', 'tabindex' => 17, 'link' => "javascript:bbcar('','{$field}',5);", 'icon' => 'ul.png');
                 // UL
                 $buttons[] = array('titre' => CopixI18N::get('wikibuttons.ol'), 'accesskey' => 'w', 'tabindex' => 17, 'link' => "javascript:bbcar('','{$field}',6);", 'icon' => 'ol.png');
                 // OL
                 break;
         }
         if ($object) {
             $user_type = _currentUser()->getExtra('type');
             $user_id = _currentUser()->getExtra('id');
             if ('USER' === $object) {
                 Kernel::createMissingModules($user_type, $user_id);
                 $parent = array('type' => $user_type, 'id' => $user_id);
             } elseif (preg_match('/^MOD_/', $object['type'])) {
                 $parent = Kernel::getModParentInfo($object['type'], $object['id']);
             } else {
                 $parent = Kernel::getNodeInfo($object['type'], $object['id']);
             }
             if ($parent) {
                 $mods = Kernel::getModEnabled($parent['type'], $parent['id']);
                 $alb = Kernel::filterModuleList($mods, 'MOD_ALBUM');
                 if ($alb && $withAlbum) {
                     $url = CopixUrl::get('album||getpopup', array('album_id' => $alb[0]->module_id, 'field' => $field, 'format' => $format));
                     $buttonAlbum = array('titre' => CopixI18N::get('wikibuttons.album'), 'accesskey' => 'a', 'tabindex' => 18, 'link' => $url);
                     // Album photos
                 }
                 $mal = Kernel::filterModuleList($mods, 'MOD_MALLE');
                 if ($mal) {
                     $url = CopixUrl::get('malle|malle|getMallePopup', array('id' => $mal[0]->module_id, 'field' => $field, 'format' => $format));
                     $buttonMalle = array('titre' => CopixI18N::get('wikibuttons.malleTxt'), 'accesskey' => 'd', 'tabindex' => 19, 'link' => $url);
                     // Malle
                 }
                 $cla = Kernel::filterModuleList($mods, 'MOD_CLASSEUR');
                 if ($cla) {
                     $url = CopixUrl::get('classeur||getClasseurPopup', array('classeurId' => $cla[0]->module_id, 'field' => $field, 'format' => $format, 'withPersonal' => 1, 'moduleType' => $object['type'], 'moduleId' => $object['id']));
                     $buttonClasseur = array('titre' => CopixI18N::get('wikibuttons.classeurTxt'), 'accesskey' => 'd', 'tabindex' => 20, 'link' => $url);
                     // Classeur
                 }
             }
         }
         $tpl->assign('format', $format);
         $tpl->assign('buttons', $buttons);
         $tpl->assign('buttonAlbum', $buttonAlbum);
         $tpl->assign('buttonMalle', $buttonMalle);
         $tpl->assign('buttonClasseur', $buttonClasseur);
         $tpl->assign('field', $field);
         $toReturn = $tpl->fetch('wikibuttons.tpl');
     }
     return true;
 }
 /**
  * Affichage du détail d'une malle
  *
  * Affiche l'ensemble des fichiers, dossiers et actions possibles de réaliser dans un dossier d'une malle
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/12/02
  * @param integer $id Id de la malle
  * @param integer $folder Id du répertoire
  * @param array $errors (option) Erreurs rencontrées
  */
 public function processGetMalle()
 {
     $kernelService =& CopixClassesFactory::Create('kernel|kernel');
     $malleService =& CopixClassesFactory::Create('malle|malleService');
     $daoMalles = CopixDAOFactory::create("malle|malle_malles");
     $daoFolders = CopixDAOFactory::create("malle|malle_folders");
     $daoFiles = CopixDAOFactory::create("malle|malle_files");
     $id = $this->getRequest('id', null);
     // Malle perso : si $id non défini ou si $id=0
     if (!$id) {
         // Récupération des infos de l'utilisateur.
         $userInfo = Kernel::getUserInfo();
         // Création des modules inexistants.
         Kernel::createMissingModules($userInfo["type"], $userInfo["id"]);
         // Liste des modules activés.
         $modsList = Kernel::getModEnabled($userInfo["type"], $userInfo["id"]);
         foreach ($modsList as $modInfo) {
             // Recherche du module de malle.
             //print_r($modInfo);
             if ($modInfo->module_type == "MOD_MALLE" && $modInfo->module_id) {
                 // Sélection de la malle personnelle.
                 $urlReturn = CopixUrl::get('malle||getMalle', array('id' => $modInfo->module_id));
                 return new CopixActionReturn(COPIX_AR_REDIRECT, $urlReturn);
             }
         }
     }
     $folder = $this->getRequest('folder', 0);
     $errors = $this->getRequest('errors', array());
     $criticErrors = array();
     if ($folder) {
         $rFolder = $daoFolders->get($folder);
         if (!$rFolder) {
             $criticErrors[] = CopixI18N::get('malle|malle.error.noFolder');
         } elseif ($rFolder->malle != $id) {
             $criticErrors[] = CopixI18N::get('malle|malle.error.noFolder');
         }
     } else {
         $rMalle = $daoMalles->get($id);
         if (!$rMalle) {
             $criticErrors[] = CopixI18N::get('malle|malle.error.noMalle');
         }
     }
     if (!$criticErrors) {
         $mondroit = $kernelService->getLevel("MOD_MALLE", $id);
         //print_r($mondroit);
         if (!$malleService->canMakeInMalle("READ", $mondroit)) {
             $criticErrors[] = CopixI18N::get('kernel|kernel.error.noRights');
         } else {
             $parent = $kernelService->getModParentInfo("MOD_MALLE", $id);
             //print_r($parent);
         }
     }
     if ($criticErrors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $criticErrors), 'back' => CopixUrl::get('malle||')));
     } else {
         // On récupère les dossiers de ce répertoire
         $folders = $daoFolders->getFoldersInFolder($id, $folder);
         // On récupère les fichiers de ce répertoire
         $files = $daoFiles->getFilesInFolder($id, $folder);
         foreach ($files as $k => $file) {
             // Ajout des infos sur le type du fichier
             $mime = $malleService->getTypeInfos($file->type, $file->fichier);
             $files[$k]->type_text = $mime['type_text'];
             $files[$k]->type_icon = $mime['type_icon'];
         }
         $dispMenu = true;
         if (substr($parent['type'], 0, 5) == 'USER_') {
             $title = CopixI18N::get('malle|malle.perso');
             $dispMenu = false;
         } else {
             $title = isset($parent["nom"]) ? $parent["nom"] : CopixI18N::get('malle.moduleDescription');
         }
         $tpl = new CopixTpl();
         $tpl->assign('TITLE_PAGE', $title);
         $can = array('file_download' => $malleService->canMakeInMalle("FILE_DOWNLOAD", $mondroit), 'file_upload' => $malleService->canMakeInMalle("FILE_UPLOAD", $mondroit), 'folder_create' => $malleService->canMakeInMalle("FOLDER_CREATE", $mondroit), 'item_delete' => $malleService->canMakeInMalle("ITEM_DELETE", $mondroit), 'item_move' => $malleService->canMakeInMalle("ITEM_MOVE", $mondroit), 'item_copy' => $malleService->canMakeInMalle("ITEM_COPY", $mondroit), 'item_rename' => $malleService->canMakeInMalle("ITEM_RENAME", $mondroit), 'item_downloadZip' => $malleService->canMakeInMalle("ITEM_DOWNLOAD_ZIP", $mondroit));
         //print_r($can);
         $nbFiles = count($files);
         $nbFolders = count($folders);
         // CONSTRUCTION DU MENU
         // S.Holtz 2010.09
         $menu = array();
         $size = 64;
         if ($can['file_upload']) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.addfile'), 'type' => 'addfile', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptAddFile', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['file_upload']) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.addweb'), 'type' => 'addfile addweb', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptAddWeb', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['folder_create']) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.addfolder'), 'type' => 'addfolder', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptAddFolder', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['item_copy'] && ($nbFiles > 0 || $nbFolders > 0)) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.copy'), 'type' => 'copy', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptCopyItems', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['item_move'] && ($nbFiles > 0 || $nbFolders > 0)) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.move'), 'type' => 'move', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptMoveItems', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['item_delete'] && ($nbFiles > 0 || $nbFolders > 0)) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.delete'), 'type' => 'delete', 'size' => $size, 'behavior' => 'fancybox', 'url' => CopixUrl::get('malle|malle|promptDeleteItems', array('id' => $id, 'folder' => $folder)));
         }
         if ($can['item_downloadZip'] && ($nbFiles > 0 || $nbFolders > 0)) {
             $menu[] = array('txt' => CopixI18N::get('malle.menu.download'), 'type' => 'download', 'size' => $size + 10, 'url' => CopixUrl::get('malle|malle|promptDownloadZip', array('id' => $id, 'folder' => $folder)));
         }
         $tpl->assign('MENU', $menu);
         // FIN CONSTRUCTION DU MENU
         $tplMalle = new CopixTpl();
         $tplMalle->assign('id', $id);
         $tplMalle->assign('folder', $folder);
         $tplMalle->assign('folders', $folders);
         $tplMalle->assign('files', $files);
         $tplMalle->assign('errors', $errors);
         $tplMalle->assign('can', $can);
         $tplMalle->assign('petitpoucet', CopixZone::process('malle|petitpoucet', array('malle' => $id, 'folder' => $folder)));
         $tplMalle->assign('combofoldersdest', CopixZone::process('malle|combofolders', array('malle' => $id, 'folder' => $folder, 'fieldName' => 'folderDest', 'attribs' => 'style="width:100%;"')));
         $tplMalle->assign('combofolders', CopixZone::process('malle|combofolders', array('malle' => $id, 'folder' => $folder, 'fieldName' => 'folder', 'attribs' => 'ONCHANGE="this.form.submit();"', 'linesSup' => array(0 => array('value' => '', 'libelle' => CopixI18N::get('malle|malle.comboDirectAccess'))))));
         $tplMalle->assign("uploadMaxSize", CopixConfig::get('malle|uploadMaxSize'));
         //Kernel::myDebug($files);
         //if ($mondroit>=PROFILE_CCV_PUBLISH)	$tplForum->assign ('canPublish', 1);
         //else																$tplForum->assign ('canPublish', 0);
         $result = $tplMalle->fetch('getmalle.tpl');
         $tpl->assign('MAIN', $result);
         return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
     }
 }
 /**
  * Affichage principal
  */
 public function processVoirContenu()
 {
     $ppo = new CopixPPO();
     _classInclude('classeur|classeurService');
     // Récupération des paramètres
     $ppo->classeurId = _request('classeurId', null);
     $ppo->dossierId = _request('dossierId', 0);
     $ppo->confirmMessage = _request('confirmMessage', null);
     $ppo->errorMessage = _request('errorMessage', null);
     $vue = _request('vue', null);
     // Paramètres de tri
     $triColonne = _request('triColonne', null);
     $triDirection = _request('triDirection', 'ASC');
     // Gestion des droits
     $ppo->withSubLockers = Kernel::getLevel('MOD_CLASSEUR', $ppo->classeurId) >= PROFILE_CCV_PUBLISH ? true : false;
     $ppo->conf_ModClasseur_upload = CopixConfig::exists('default|conf_ModClasseur_upload') ? CopixConfig::get('default|conf_ModClasseur_upload') : 0;
     // Récupération de l'identifiant du classeur personnel si non disponible en session
     if (is_null($ppo->idClasseurPersonnel = _sessionGet('classeur|idClasseurPersonnel'))) {
         // Création des modules inexistants.
         Kernel::createMissingModules(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
         $modsList = Kernel::getModEnabled(_currentUser()->getExtra('type'), _currentUser()->getExtra('id'));
         foreach ($modsList as $modInfo) {
             if ($modInfo->module_type == 'MOD_CLASSEUR' && $modInfo->module_id) {
                 _sessionSet('classeur|idClasseurPersonnel', $modInfo->module_id);
                 $ppo->idClasseurPersonnel = _sessionGet('classeur|idClasseurPersonnel');
             }
         }
     }
     // Si ID du classeur non spécifié, on récupère l'identifiant du classeur perso disponible en session
     if (is_null($ppo->classeurId)) {
         $ppo->classeurId = _sessionGet('classeur|idClasseurPersonnel');
     }
     // Si type de vue spécifié, on le met en session et on le stocke en BDD
     $kernelConfUserDAO = _ioDAO('kernel|kernel_conf_user');
     if (!is_null($vue) && ($vue == 'liste' || $vue == 'vignette')) {
         _sessionSet('classeur|typeVue', $vue);
         $confVue = $kernelConfUserDAO->getByPathAndUserId('/module_classeur/vue', _currentUser()->getExtra('id'));
         if ($confVue) {
             $confVue->value = $vue;
             $kernelConfUserDAO->update($confVue);
         } else {
             $kernelConfUser = _record('kernel|kernel_conf_user');
             $kernelConfUser->path = '/module_classeur/vue';
             $kernelConfUser->id_dbuser = _currentUser()->getExtra('id');
             $kernelConfUser->value = $vue;
             $kernelConfUserDAO->insert($kernelConfUser);
         }
     }
     // Récupération de la vue en session ou BDD
     if (!is_null(_sessionGet('classeur|typeVue'))) {
         $ppo->vue = _sessionGet('classeur|typeVue');
     } else {
         $confVue = $kernelConfUserDAO->getByPathAndUserId('/module_classeur/vue', _currentUser()->getExtra('id'));
         if ($confVue) {
             _sessionSet('classeur|typeVue', $vue);
             $ppo->vue = _sessionGet('classeur|typeVue');
         } else {
             _sessionSet('classeur|typeVue', 'liste');
             $kernelConfUser = _record('kernel|kernel_conf_user');
             $kernelConfUser->path = '/module_classeur/vue';
             $kernelConfUser->id_dbuser = _currentUser()->getExtra('id');
             $kernelConfUser->value = 'liste';
             $kernelConfUserDAO->insert($kernelConfUser);
         }
     }
     // Si tri spécifié, mise en session
     if (!is_null($triColonne)) {
         ClasseurService::setContentSort($triColonne, $triDirection);
     }
     // Ouverture du dossier courant dans l'arborescence
     if ($ppo->dossierId != 0) {
         classeurService::openTree($ppo->classeurId, $ppo->dossierId);
     }
     $modParentInfo = Kernel::getModParentInfo('MOD_CLASSEUR', $ppo->classeurId);
     $ppo->TITLE_PAGE = $modParentInfo['nom'];
     $classeurDAO = _ioDAO('classeur|classeur');
     $folderDAO = _ioDAO('classeur|classeurdossier');
     $fichierDAO = _ioDAO('classeur|classeurfichier');
     $classeur = $classeurDAO->get($ppo->classeurId);
     $folder = $folderDAO->get($classeur->upload_db);
     if ($ppo->conf_ModClasseur_upload && $classeur->upload_fs) {
         $nomClasseur = $classeur->id . '-' . $classeur->cle;
         // $extension  = strtolower(strrchr($fichier->fichier, '.'));
         // $nomFichier = $fichier->id.'-'.$fichier->cle.$extension;
         $path = realpath('./upload') . '/' . $classeur->upload_fs;
         if ($classeur->upload_fs && glob($path . '/*')) {
             foreach (glob($path . '/*') as $file) {
                 if (is_file($file)) {
                     $fichier = _record('classeur|classeurfichier');
                     $title = Kernel::stripText($file);
                     $fichier->classeur_id = $classeur->id;
                     $fichier->dossier_id = $classeur->upload_db;
                     // TODO : Verifier existance
                     $fichier->titre = substr(basename($file), 0, 63);
                     $fichier->commentaire = '';
                     $fichier->fichier = basename($file);
                     $fichier->taille = file_exists($file) ? filesize($file) : 0;
                     $fichier->type = strtoupper(substr(strrchr($file, '.'), 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');
                     $fichierDAO->insert($fichier);
                     $nomClasseur = $classeur->id . '-' . $classeur->cle;
                     $nomFichier = $fichier->id . '-' . $fichier->cle;
                     $extension = strtolower(strrchr($file, '.'));
                     $dir = realpath('./static/classeur') . '/' . $classeur->id . '-' . $classeur->cle . '/';
                     // Déplacement du fichier temporaire dans le classeur
                     copy($file, $dir . $fichier->id . '-' . $fichier->cle . $extension);
                     ClasseurService::doAutoRotateJpegByOrientation($dir . $fichier->id . '-' . $fichier->cle . $extension, $extension);
                     // Suppression du fichier temporaire
                     unlink($file);
                 }
                 if ($classeur->upload_db) {
                     classeurService::updateFolderInfos($folder);
                 }
             }
         }
         // print_r($classeur);
         // upload_fs
     }
     return _arPPO($ppo, 'voir_contenu.tpl');
 }
Пример #21
0
 public function createMissingModules($node_type, $node_id)
 {
     $modavailable = Kernel::getModAvailable($node_type);
     $modenabled = Kernel::getModEnabled($node_type, $node_id, _currentUser()->getExtra('type'), _currentUser()->getExtra('id'), 1);
     $modinstalled = array();
     foreach ($modenabled as $module) {
         $modinstalled[] = strtolower($module->module_type);
     }
     //var_dump($modinstalled);
     $nodeInfo = Kernel::getNodeInfo($node_type, $node_id);
     if ($node_type == 'CLUB') {
         foreach ($modavailable as $module) {
             // echo "<li>".$module->module_type."</li>";
             if ($module->module_type == 'MOD_MAGICMAIL') {
                 $modname = 'magicmail';
                 // _dump($modinstalled);
                 // if( array_search("mod_magicmail", $modinstalled)===false ) echo "magicmail ";
                 // if( array_search("mod_blog", $modinstalled)!==false ) echo "blog ";
                 if (array_search("mod_magicmail", $modinstalled) === false && array_search("mod_blog", $modinstalled) !== false) {
                     $file =& CopixSelectorFactory::create($modname . "|" . $modname);
                     $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php';
                     //var_dump($filePath);
                     if (is_readable($filePath)) {
                         $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname);
                         if (method_exists($modservice, "create")) {
                             $subtitle = $node_type == 'BU_ECOLE' && isset($nodeInfo['ALL']->eco_type) ? $nodeInfo['ALL']->eco_type : '';
                             $prenom = isset($nodeInfo['prenom']) ? $nodeInfo['prenom'] : '';
                             $modid = $modservice->create(array('title' => trim($prenom . ' ' . $nodeInfo['nom']), 'subtitle' => $subtitle, 'node_type' => $node_type, 'node_id' => $node_id));
                             if ($modid != null) {
                                 // _dump( array( $module->module_type, $modid, $node_type, $node_id ));
                                 Kernel::registerModule($module->module_type, $modid, $node_type, $node_id);
                             }
                         }
                     }
                 }
             }
         }
         return false;
     }
     foreach ($modavailable as $module) {
         //var_dump($module);
         if (preg_match("/^MOD_(.+)\$/", $module->module_type, $modinfo)) {
             $modname = strtolower($modinfo[1]);
             if (array_search("mod_" . $modname, $modinstalled) === false) {
                 $file =& CopixSelectorFactory::create($modname . "|" . $modname);
                 $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php';
                 //var_dump($filePath);
                 if (is_readable($filePath)) {
                     $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname);
                     if (method_exists($modservice, "create")) {
                         $subtitle = $node_type == 'BU_ECOLE' && isset($nodeInfo['ALL']->eco_type) ? $nodeInfo['ALL']->eco_type : '';
                         $prenom = isset($nodeInfo['prenom']) ? $nodeInfo['prenom'] : '';
                         $modid = $modservice->create(array('title' => trim($prenom . ' ' . $nodeInfo['nom']), 'subtitle' => $subtitle, 'node_type' => $node_type, 'node_id' => $node_id));
                         if ($modid != null) {
                             Kernel::registerModule($module->module_type, $modid, $node_type, $node_id);
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Suppression effective d'un groupe
  *
  * @author Christophe Beyer <*****@*****.**>
  * @since 2005/11/16
  * @see getDelete()
  * @param integer $id Id du groupe
  */
 public function doDelete()
 {
     $dao = CopixDAOFactory::create("groupe");
     $kernel_service =& CopixClassesFactory::Create('kernel|kernel');
     $groupeService =& CopixClassesFactory::Create('groupe|groupeService');
     $errors = array();
     $id = $this->getRequest('id', null);
     $groupe = $dao->getGroupe($id);
     if (!$groupe) {
         $errors[] = CopixI18N::get('groupe|groupe.error.noGroup');
     }
     $mondroit = $kernel_service->getLevel("CLUB", $id);
     if (!$groupeService->canMakeInGroupe('ADMIN', $mondroit)) {
         $errors[] = CopixI18N::get('kernel|kernel.error.noRights');
     }
     if ($errors) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => implode('<br/>', $errors), 'back' => CopixUrl::get('groupe||')));
     } else {
         // On supprime ses modules
         $his_modules = Kernel::getModEnabled("CLUB", $id);
         foreach ($his_modules as $k => $node) {
             list(, $module) = explode("_", $node->module_type);
             $module = strtolower($module);
             $classeModule =& CopixClassesFactory::create($module . '|Kernel' . $module);
             if (method_exists($classeModule, "delete")) {
                 $classeModule->delete($node->module_id);
             }
         }
         // On supprime tous les noeuds
         $daoKernelModEnabled = CopixDAOFactory::create("kernel|kernel_mod_enabled");
         $daoKernelModEnabled->delByNode("CLUB", $id);
         // On supprime le rattachement du groupe
         $daoLinkGroupe2Node = CopixDAOFactory::create("kernel|kernel_link_groupe2node");
         $daoLinkGroupe2Node->delete($id);
         // On supprime les membres/droits
         $childs = Kernel::getNodeChilds("CLUB", $id);
         foreach ($childs as $user) {
             Kernel::setLevel("CLUB", $id, $user["type"], $user["id"], 0);
         }
         // On supprime le groupe lui-m�me
         $dao->delete($id);
     }
     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('groupe||getListMy'));
 }
 /**
  * Préparation de l'édition d'un blog.
  */
 public function processGetShowBlog()
 {
     $id_blog = $this->getRequest('id_blog', null);
     $blogDAO = CopixDAOFactory::create('blog|blog');
     $blog = $blogDAO->get($id_blog);
     if (!BlogAuth::canMakeInBlog('ACCESS_ADMIN', $blog)) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.cannotManageBlog'), 'back' => $blog ? CopixUrl::get('|', array('blog' => $blog->url_blog)) : CopixUrl::get('||')));
     }
     if ($id_blog == null) {
         return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('blog.error.param'), 'back' => CopixUrl::get('||')));
     }
     $kind = $this->getRequest('kind', '0');
     $tpl = new CopixTpl();
     $tabBlogFunctions = null;
     $result = null;
     if ($kind == '0') {
         // Articles
         CopixHTMLHeader::addCSSLink(_resource("styles/module_blog.css"));
         $selectCategory = $this->getRequest('selectCategory', '');
         $selectMonth = $this->getRequest('selectMonth', '');
         $id_bact = $this->getRequest('id_bact', '');
         $result = CopixZone::process('ShowBlogArticle', array('id_blog' => $id_blog, 'blog' => $blog, 'kind' => $kind, 'selectCategory' => $selectCategory, 'selectMonth' => $selectMonth, 'id_bact' => $id_bact, 'p' => $this->getRequest('p', '')));
     } else {
         if ($kind == '1') {
             // Catégories
             $result = CopixZone::process('ShowBlogCategory', array('id_blog' => $id_blog, 'kind' => $kind));
         } else {
             if ($kind == '2') {
                 // Liens
                 $result = CopixZone::process('ShowBlogLink', array('id_blog' => $id_blog, 'kind' => $kind));
             } else {
                 if ($kind == '3') {
                     // Photos
                     $can = BlogAuth::canMakeInBlog('ADMIN_PHOTOS', $blog);
                     if ($can) {
                         $parent = Kernel::getModParentInfo("MOD_BLOG", $id_blog);
                         if ($parent) {
                             $mods = Kernel::getModEnabled($parent['type'], $parent['id']);
                             $mods = Kernel::filterModuleList($mods, 'MOD_ALBUM');
                             if ($mods && $mods[0]) {
                                 return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('album||go', array('id' => $mods[0]->module_id)));
                             }
                         }
                     }
                     // Si on arrive là, c'est pas normal
                     $result = CopixZone::process('ShowBlogPhoto', array('id_blog' => $id_blog, 'kind' => $kind));
                 } else {
                     if ($kind == '7') {
                         // Documents
                         $can = BlogAuth::canMakeInBlog('ADMIN_DOCUMENTS', $blog);
                         if ($can) {
                             $parent = Kernel::getModParentInfo("MOD_BLOG", $id_blog);
                             if ($parent) {
                                 $mods = Kernel::getModEnabled($parent['type'], $parent['id']);
                                 $mods = Kernel::filterModuleList($mods, 'MOD_MALLE');
                                 if ($mods && $mods[0]) {
                                     return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('malle||go', array('id' => $mods[0]->module_id)));
                                 }
                             }
                         }
                         // Si on arrive là, c'est pas normal
                         $result = CopixZone::process('ShowBlogDocument', array('id_blog' => $id_blog, 'kind' => $kind));
                     } else {
                         if ($kind == '5') {
                             // Pages
                             $result = CopixZone::process('ShowBlogPage', array('id_blog' => $id_blog, 'kind' => $kind));
                         } else {
                             if ($kind == '6') {
                                 // RSS
                                 $result = CopixZone::process('ShowBlogFluxRss', array('id_blog' => $id_blog, 'kind' => $kind));
                             } else {
                                 if ($kind == '8') {
                                     // Droits particuliers sur le blog
                                     $result = CopixZone::process('ShowBlogDroits', array('blog' => $blog, 'kind' => $kind, 'errors' => $this->getRequest('errors'), 'membres' => $this->getRequest('membres'), 'droit' => $this->getRequest('droit')));
                                 } else {
                                     if ($kind == '9') {
                                         // Stats du blog
                                         $result = CopixZone::process('stats|module', array('module_type' => 'MOD_BLOG', 'module_id' => $id_blog, 'date' => $this->getRequest('date'), 'mois' => $this->getRequest('mois'), 'annee' => $this->getRequest('annee'), 'url' => CopixUrl::get('blog|admin|showBlog', array("id_blog" => $id_blog, "kind" => $kind)), 'errors' => $this->getRequest('errors')));
                                     } else {
                                         // Options
                                         $kind = 4;
                                         $tabFunctions = returnAllBlogFunctions();
                                         $blogFunctionsDAO = CopixDAOFactory::create('blog|blogfunctions');
                                         $resBlogFunctions = $blogFunctionsDAO->get($id_blog);
                                         $tabBlogFunctions = array();
                                         if ($resBlogFunctions != null) {
                                             foreach ($tabFunctions as $fct) {
                                                 eval('if($resBlogFunctions->' . $fct->value . '==\'1\')array_push($tabBlogFunctions, $fct);');
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $menu = getBlogAdminMenu($blog, $kind);
     $tpl->assign('TITLE_PAGE', $blog->name_blog);
     $tpl->assign('MENU', $menu);
     // _dump($blog);
     $tpl->assign('MAIN', CopixZone::process('ShowBlog', array('id_blog' => $id_blog, 'blog' => $blog, 'kind' => $kind, 'tabBlogFunctions' => $tabBlogFunctions, 'RESULT' => $result)));
     return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl);
 }