/** * 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 getList() { $dao =& CopixDAOFactory::create('copix:CopixCapability'); $sp =& CopixDAOFactory::createSearchParams(); $sp->orderBy('name_ccpb'); return $dao->findBy($sp); }
/** * Fonction qui est appel�e lors de la modification d'un �v�nement * R�cup�re l'objet 'event' en base de donn�es gr�ce � l'id_event * R�dirige vers l'action "edit" de l'actiongroup */ public function doPrepareEdit() { $serviceAuth = new AgendaAuth(); //r�cup�ration de l'objet event en base de donn�e $daoSearchParams =& CopixDAOFactory::createSearchParams(); $daoSearchParams->addCondition('id_event', '=', _request('id_event')); $daoEvent =& CopixDAOFactory::getInstanceOf('Event'); $arEvent = $daoEvent->findBy($daoSearchParams); if (count($arEvent) > 0) { $event = $arEvent[0]; } else { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.eventnotinbase'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine'))); } //on v�rifie si l'utilisateur a les droits de modification sur l'agenda concern� if ($serviceAuth->getCapability($event->id_agenda) < $serviceAuth->getModerate()) { return CopixActionGroup::process('genericTools|Messages::getError', array('message' => CopixI18N::get('agenda.error.enableToWrite'), 'back' => CopixUrl::get('agenda|agenda|vueSemaine'))); } //$event->datedeb_event = DateService::dateBddToDateFr($event->datedeb_event); //$event->datedeb_event = CopixDateTime::timestampToDate($event->datedeb_event, ''); //$event->datefin_event = DateService::dateBddToDateFr($event->datefin_event); //$event->datefin_event = CopixDateTime::timestampToDate($event->datefin_event, ''); //$event->endrepeatdate_event = ($event->endrepeatdate_event) ? DateService::dateBddToDateFr($event->endrepeatdate_event) : ''; //$event->endrepeatdate_event = ($event->endrepeatdate_event) ? CopixDateTime::timestampToDate($event->endrepeatdate_event, '') : ''; $this->_setSessionEvent($event); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('agenda|event|edit')); }
/** * @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; }
/** * 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); } }
/** * 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; }
/** * 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; }
/** * Description d'une méthode de DAO */ public function CopixMethodForDAO($method, $def) { $this->_def = $def; $attributes = array(); foreach ($method->attributes() as $key => $value) { $attributes[strtolower($key)] = (string) $value; } if (!isset($attributes['name'])) { throw new Exception(_i18n('copix:dao.error.definitionfile.missing.attr', array('name', 'method'))); } $this->name = $attributes['name']; $this->type = isset($attributes['type']) ? strtolower($attributes['type']) : 'select'; if (isset($method->parameters) && isset($method->parameters->parameter)) { foreach ($method->parameters->parameter as $param) { $this->addParameter($param->attributes()); } } if (isset($method->conditions)) { $methodConditionsAttributes = array(); foreach ($method->conditions->attributes() as $key => $name) { $methodConditionsAttributes[strtolower($key)] = (string) $name; } if (isset($methodConditionsAttributes['logic'])) { $kind = $methodConditionsAttributes['logic']; } else { $kind = 'AND'; } $this->_searchParams = CopixDAOFactory::createSearchParams($kind); $this->_parseConditions($method, true); } else { $this->_searchParams = CopixDAOFactory::createSearchParams('AND'); } if ($this->type == 'update') { if (isset($method->values) && isset($method->values->value)) { foreach ($method->values->value as $val) { $this->addValue($val->attributes()); } } else { throw new Exception(_i18n('copix:dao.error.definitionfile.method.values.undefine', array($this->name))); } } if (isset($method->order) && isset($method->order->orderitem)) { foreach ($method->order->orderitem as $item) { $this->addOrder($item->attributes()); } } if (isset($method->limit)) { if (count($method->limit) > 1) { throw new Exception(_i18n('copix:dao.error.definitionfile.tag.duplicate', array('limit', $this->name))); } if ($this->type == 'select' || $this->type == 'selectfirst') { $attr = $method->limit->attributes(); $offset = isset($attr['offset']) ? $attr['offset'] : null; $count = isset($attr['count']) ? $attr['count'] : null; if ($offset === null) { throw new Exception(_i18n('copix:dao.error.definitionfile.missing.attr', array('offset', 'limit'))); } if ($count === null) { throw new Exception(_i18n('copix:dao.error.definitionfile.missing.attr', array('count', 'limit'))); } if (substr($offset, 0, 1) == '$') { if (in_array(substr($offset, 1), $this->_parameters)) { $offset = ' intval(' . $offset . ')'; } else { throw new Exception(_i18n('copix:dao.error.definitionfile.method.limit.parameter.unknow', array('CopixMethodForDAO', $this->name, $offset))); } } else { if (1 || is_numeric($offset)) { $offset = $offset * 1; $offset = intval($offset); } else { throw new Exception(_i18n('copix:dao.error.definitionfile.method.limit.badvalue', array('CopixMethodForDAO', $this->name, $offset))); } } if (substr($count, 0, 1) == '$') { if (in_array(substr($count, 1), $this->_parameters)) { $count = ' intval(' . $count . ')'; } else { throw new Exception(_i18n('copix:dao.error.definitionfile.method.limit.parameter.unknow', array('CopixMethodForDAO', $this->name, $count))); } } else { if (1 || is_numeric($count)) { $count = intval($count); } else { throw new Exception(_i18n('copix:dao.error.definitionfile.method.limit.badvalue', array('CopixMethodForDAO', $this->name, $count))); } } $this->_limit = compact('offset', 'count'); } else { throw new Exception(_i18n('copix:dao.error.definitionfile.method.limit.forbidden')); } } }
/** * Get the configVars from dao group array * We will not load values that do not exists in the XML file. * We will only load the values of the config variables, not their captions or so. * We remind that the database here is just a _Saving_ purpose in case the "temp" directory is deleted. * We will test the presence of the CopixDB plugin to store values in the database. */ function _loadFromDatabase() { if (!$this->_checkDBConnection()) { return; } $dao =& CopixDAOFactory::create('copix:CopixConfig'); $sp =& CopixDAOFactory::createSearchParams(); $sp->addCondition('group_ccfg', '=', $this->group); $arVars = $dao->findBy($sp); foreach ($arVars as $vars) { if (isset($this->_configVars[$vars->id_ccfg])) { $this->_configVars[$vars->id_ccfg]['Value'] = $vars->value_ccfg; } } }
/** * Gets capabilities descriptions */ function getDescriptions() { $sp = CopixDAOFactory::createSearchParams(); $sp->orderBy('name_ccpb'); //search $dao =& CopixDAOFactory::create('copix:CopixCapability'); $results = $dao->findBy($sp); //we only wants names $toReturn = array(); foreach ($results as $cap) { $toReturn[$cap->name_ccpb] = $cap->description_ccpb; } return $toReturn; }
/** * gets the user list * @param string $pattern the pattern we're looking for (does not contains any special char) * @return array */ function findByLogin($pattern) { $dao =& CopixDAOFactory::create($this->_dao); $sp =& CopixDAOFactory::createSearchParams(); $sp->addCondition($this->_loginField, 'like', '%' . $pattern . '%'); return $dao->findBy($sp); }
/** * Alias à CopixDAOFactory::createSearchParams * @param string $pKind Le type de gestion des conditions par défaut * @return CopixDAOSearchParams */ function _daoSP($pKind = 'AND') { return CopixDAOFactory::createSearchParams($pKind); }