/** * Retorna um contato recente * * @license http://www.gnu.org/copyleft/gpl.html GPL * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) * @sponsor Caixa Econômica Federal * @author José Vicente Tezza Jr. * @return Retorna um contato recente * @access public * */ function get($request, $id) { $this->secured(); //verificar se a preferencia de contatos dinamicos nao esta ativada if (!$this->isEnabledDynamicContacts(Config::me("uidNumber"))) { $response = new Response($request); $this->createException($request, $response, Response::UNAUTHORIZED, 'Resource unauthorized', 'disabled dynamic contacts preference'); return $response; } $response = new Response($request); $response->addHeader('Content-type', 'aplication/json'); $response->code = Response::OK; $h = new Hypermedia(); $c = new Collection($request->resources, 'DynamicContactResource', $id); try { $dynamicContact = Controller::read(array('concept' => 'dynamicContact'), false, array('filter' => array('AND', array('=', 'owner', Config::me("uidNumber")), array('=', 'id', $id)))); //Se nao foi encontrado contatos na consulta if (!$dynamicContact) { $this->createException($request, $response, Response::NOTFOUND, 'Bad request', 'Dynamic Contact not found.'); return $response; } //Normaliza dado if (is_array($dynamicContact)) { $dynamicContact = $dynamicContact[0]; } $t = new Template(); $d = new Data(); $d->setName('name'); $d->setValue(null); $d->setPrompt('Nome do Contato Recente'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $d = new Data(); $d->setName('mail'); $d->setValue(null); $d->setPrompt('Email do Contato Recente'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $d = new Data(); $d->setName('number_of_messages'); $d->setValue(null); $d->setPrompt('Quantidade de mensagens enviadas'); $d->setDataType('integer'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(false); $t->addData($d); $c->setTemplate($t); $d = new Data(); $d->setName('id'); $d->setValue($dynamicContact['id']); $d->setPrompt('Identificador do Contato Recente'); $d->setDataType('integer'); $d->setMaxLength(null); $d->setMinLength(null); $d->setRequired(true); $c->addData($d); $d = new Data(); $d->setName('name'); $d->setValue($dynamicContact['name']); $d->setPrompt('Nome do Contato Recente'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $c->addData($d); $d = new Data(); $d->setName('mail'); $d->setValue($dynamicContact['mail']); $d->setPrompt('Email do Contato Recente'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $c->addData($d); $d = new Data(); $d->setName('number_of_messages'); $d->setValue($dynamicContact['number_of_messages']); $d->setPrompt('Quantidade de mensagens enviadas'); $d->setDataType('integer'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(false); $c->addData($d); $l = new Link(); $l->setHref(''); $l->setRel('delete'); $l->setAlt('Remover'); $l->setPrompt('Remover'); $l->setRender('link'); $c->addLink($l); $l = new Link(); $l->setHref(''); $l->setRel('put'); $l->setAlt('Atualizar'); $l->setPrompt('Atualizar'); $l->setRender('link'); $c->addLink($l); $h->setCollection($c); } catch (Exception $ex) { $this->createException($request, $response, Response::INTERNALSERVERERROR, 'Internal Server Error', 'Internal Server Error'); return $response; } $response->body = $h->getHypermedia($request->accept[10][0]); return $response; }
/** * Retorna uma lista de usuários * * @license http://www.gnu.org/copyleft/gpl.html GPL * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) * @sponsor Caixa Econômica Federal * @author José Vicente Tezza Jr. * @return Retorna uma lista de usuários do LDAP * @access public * */ function get($request, $id) { $response = new Response($request); $response->addHeader('Content-type', 'aplication/json'); $response->code = Response::OK; $h = new Hypermedia(); $c = new Collection($request->resources, 'PersonalContactResource'); try { $this->secured(); $contacts = !!$id ? Controller::find(array('concept' => 'contact'), false, array('filter' => array('AND', array('=', 'user', Config::me("uidNumber")), array('=', 'id', $id)))) : Controller::find(array('concept' => 'contact'), false, array('filter' => array('=', 'user', Config::me("uidNumber")))); //Se nao foi encontrado contatos na consulta if ($contacts === false) { $error = new Error(); $error->setCode(Response::NOTFOUND); $error->setTitle('Contacts not found'); $error->setDescription('Contacts not found.'); $c->setError($error); $h->setCollection($c); $response->code = Response::NOTFOUND; $response->body = $h->getHypermedia($request->accept[10][0]); return $response; } foreach ($contacts as $value) { $i = new Item($request->resources, 'PersonalContactResource', $value['id']); $d = new Data(); $d->setName('name'); $d->setValue($value['name']); $d->setPrompt('Nome do Contato'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('id'); $d->setValue($value['id']); $d->setPrompt('Id do Contato'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('email'); $d->setValue($value['email']); $d->setPrompt('Email do Contato'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $l = new Link(); $l->setHref(''); $l->setRel('delete'); $l->setAlt('Remover'); $l->setPrompt('Remover'); $l->setRender('link'); $i->addLink($l); $l = new Link(); $l->setHref(''); $l->setRel('put'); $l->setAlt('Atualizar'); $l->setPrompt('Atualizar'); $l->setRender('link'); $i->addLink($l); $l = new Link(); $l->setHref('/contact/' . $value['id']); $l->setRel('get'); $l->setAlt('Buscar'); $l->setPrompt('Buscar'); $l->setRender('link'); $i->addLink($l); $c->addItem($i); } $t = new Template(); $d = new Data(); $d->setName('name'); $d->setValue(null); $d->setPrompt('Nome do Contato'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $d = new Data(); $d->setName('email'); $d->setValue(null); $d->setPrompt('Email do Contato'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $d = new Data(); $d->setName('telefone'); $d->setValue(null); $d->setPrompt('Telefone do Contato'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $c->setTemplate($t); $h->setCollection($c); } catch (Exception $ex) { $error = new Error(); $error->setCode(Response::INTERNALSERVERERROR); $error->setTitle('Internal Server Error'); $error->setDescription($ex); $c->setError($error); $h->setCollection($c); $response->code = Response::INTERNALSERVERERROR; $response->body = $h->getHypermedia($request->accept[10][0]); return $response; } $response->body = $h->getHypermedia($request->accept[10][0]); return $response; }
/** * Retorna uma lista de usuários * * @license http://www.gnu.org/copyleft/gpl.html GPL * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) * @sponsor Caixa Econômica Federal * @author José Vicente Tezza Jr. * @return Retorna um usuário do LDAP filtrado pelo atributo 'uid' * @access public * */ function get($request, $id) { $response = new Response($request); $response->addHeader('Content-type', 'aplication/json'); $response->code = Response::OK; $h = new Hypermedia(); $c = new Collection($request->resources, 'UserResource'); try { $this->secured(); $user = Controller::find(array('concept' => 'user', 'service' => 'OpenLDAP'), false, array('filter' => array('=', 'uid', $id), 'notExternal' => true)); //Se nao foi encontrado usuario na consulta if ($user === false) { $error = new Error(); $error->setCode(Response::NOTFOUND); $error->setTitle('UserLDAP not found'); $error->setDescription('User not found.'); $c->setError($error); $h->setCollection($c); $response->code = Response::NOTFOUND; $response->body = $h->getHypermedia($request->accept[10][0]); return $response; } $t = new Template(); $d = new Data(); $d->setName('name'); $d->setValue(null); $d->setPrompt('Nome do Usuário'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $d = new Data(); $d->setName('email'); $d->setValue(null); $d->setPrompt('Email do Usuário'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $d = new Data(); $d->setName('telefone'); $d->setValue(null); $d->setPrompt('Telefone do Usuário'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $c->setTemplate($t); $d = new Data(); $d->setName('name'); $d->setValue($user[0]['name']); $d->setPrompt('Nome do Usuário'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $c->addData($d); $d = new Data(); $d->setName('email'); $d->setValue($user[0]['mail']); $d->setPrompt('Email do Usuário'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $c->addData($d); $d = new Data(); $d->setName('telephoneNumber'); $d->setValue($user[0]['telephoneNumber']); $d->setPrompt('Telefone do Usuário'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $c->addData($d); $l = new Link(); $l->setHref(''); $l->setRel('delete'); $l->setAlt('Remover'); $l->setPrompt('Remover'); $l->setRender('link'); $c->addLink($l); $l = new Link(); $l->setHref(''); $l->setRel('put'); $l->setAlt('Atualizar'); $l->setPrompt('Atualizar'); $l->setRender('link'); $c->addLink($l); $h->setCollection($c); } catch (Exception $ex) { $error = new Error(); $error->setCode(Response::INTERNALSERVERERROR); $error->setTitle('Internal Server Error'); $error->setDescription($ex); $c->setError($error); $h->setCollection($c); $response->code = Response::INTERNALSERVERERROR; $response->body = $h->getHypermedia($request->accept[10][0]); return $response; } $response->body = $h->getHypermedia($request->accept[10][0]); return $response; }
$oLnkAddJob = new Link(); $oLnkAddJob->setMultiLink("news", "", "news", "news_add_job"); $oLnkAddJob->setCustom("idnewsletter", $idnewsletter); $oLnkAddJob->setAlt($aMsg["AddJobTitle"]); $oLnkAddJob->setContent('<img src="' . $cfg['path']['images'] . 'newsletter_dispatch_16.gif" border="0" title="' . $aMsg["AddJobTitle"] . '" alt="' . $aMsg["AddJobTitle"] . '">'); $sLnkAddJob = $oLnkAddJob->render(); } else { $sLnkAddJob = '<img src="' . $cfg['path']['images'] . 'newsletter_dispatch_16_off.gif" border="0" title="' . $aMsg["AddJobTitleOff"] . '" alt="' . $aMsg["AddJobTitleOff"] . '" />'; } $oMenu->setActions($iMenu, 'dispatch', $sLnkAddJob); } if ($perm->have_perm_area_action($area, "news_create")) { $oLnkCopy = new Link(); $oLnkCopy->setMultiLink("news", "", "news", "news_duplicate"); $oLnkCopy->setCustom("idnewsletter", $idnewsletter); $oLnkCopy->setAlt($aMsg["CopyTitle"]); $oLnkCopy->setContent('<img src="' . $cfg['path']['images'] . 'but_copy.gif" border="0" title="' . $aMsg["CopyTitle"] . '" alt="' . $aMsg["CopyTitle"] . '">'); $oMenu->setActions($iMenu, 'copy', $oLnkCopy->render()); } if ($perm->have_perm_area_action($area, "news_delete")) { $sDelete = '<a title="' . $aMsg["DelTitle"] . '" href="javascript://" onclick="showDelMsg(' . $idnewsletter . ',\'' . addslashes($sName) . '\')"><img src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . $aMsg["DelTitle"] . '" alt="' . $aMsg["DelTitle"] . '"></a>'; $oMenu->setActions($iMenu, 'delete', $sDelete); } } // Check destination for sending test newsletter if ($_REQUEST["selTestDestination"] > 0 && $perm->have_perm_area_action($area, "news_send_test")) { $oRcpGroups = new RecipientGroupCollection(); $oRcpGroups->setWhere("idclient", $client); $oRcpGroups->setWhere("idlang", $lang); $oRcpGroups->setWhere($oRcpGroups->primaryKey, $_REQUEST["selTestDestination"]); $oRcpGroups->query();
/** * Retorna uma lista de usuários * * @license http://www.gnu.org/copyleft/gpl.html GPL * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) * @sponsor Caixa Econômica Federal * @author José Vicente Tezza Jr. * @return Retorna uma lista de usuários do LDAP * @access public * */ function get($request) { $response = new Response($request); $response->addHeader('Content-type', 'aplication/json'); $response->code = Response::OK; $h = new Hypermedia(); $c = new Collection($request->resources, 'UsersResource'); $this->secured(); try { //Executa uma consulta de usuários do LDAP a partir de um determinado atributo e valor if (isset($_GET['field']) && isset($_GET['value'])) { //recupera os atributos definidos no conceito 'user' $map = Config::get('user', 'OpenLDAP.mapping'); //verifica se o campo(atributo) passado pelo usuário está definido no conceito 'user' if (isset($map[$_GET['field']])) { $users = Controller::find(array('concept' => 'user', 'service' => 'OpenLDAP'), false, array('filter' => array('=', $_GET['field'], $_GET['value']), 'notExternal' => true)); } else { //lança warning no log do Expresso trigger_error("Invalid field (" . $_GET['field'] . ") in the query.", E_USER_WARNING); //formata os atributos LDAP do conceito 'user' $attributes = implode(', ', $map); //Configura o erro na hypermedia $error = new Error(); $error->setCode(Response::NOTFOUND); $error->setTitle('UserLDAP not found'); $error->setDescription("Invalid field (" . $_GET['field'] . ") in the query. Use of these: " . $attributes); $c->setError($error); $h->setCollection($c); //retorna a hypermedia $response->code = Response::NOTFOUND; $response->body = $h->getHypermedia($request->accept[10][0]); return $response; } } else { //Executa a consulta dos primeiros 20 usuarios do LDAP $users = Controller::find(array('concept' => 'user', 'service' => 'OpenLDAP'), false, array('filter' => array('=', 'phpgwAccountType', 'u'), 'limit' => 20, 'notExternal' => true)); } //Se nao foi encontrado usuarios na consulta if ($users === false) { $error = new Error(); $error->setCode(Response::NOTFOUND); $error->setTitle('UserLDAP not found'); $error->setDescription('Users not found.'); $c->setError($error); $h->setCollection($c); $response->code = Response::NOTFOUND; $response->body = $h->getHypermedia($request->accept[10][0]); return $response; } foreach ($users as $value) { $d = new Data(); $i = new Item($request->resources, 'UsersResource', $value['uid']); $d->setName('name'); $d->setValue($value['name']); $d->setPrompt('Nome do Usuario'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('email'); $d->setValue($value['mail']); $d->setPrompt('Email do Usuario'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('telephoneNumber'); $d->setValue($value['telephoneNumber']); $d->setPrompt('Telefone do Usuario'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('vacationActive'); $d->setValue($value['vacationActive']); $d->setPrompt('Status da Regra fora de Escritorio'); $d->setDataType('boolean'); $d->setMaxLength('10'); $d->setMinLength(null); $d->setRequired(null); $i->addData($d); $d = new Data(); $d->setName('vacationInfo'); $d->setValue($value['vacationInfo']); $d->setPrompt('Mensagem da Regra fora de Escritorio'); $d->setDataType('boolean'); $d->setMaxLength('10'); $d->setMinLength(null); $d->setRequired(null); $i->addData($d); $l = new Link(); $l->setHref(''); $l->setRel('delete'); $l->setAlt('Remover'); $l->setPrompt('Remover'); $l->setRender('link'); $i->addLink($l); $l = new Link(); $l->setHref(''); $l->setRel('put'); $l->setAlt('Atualizar'); $l->setPrompt('Atualizar'); $l->setRender('link'); $i->addLink($l); $l = new Link(); $l->setHref('/userldap/' . $value['uid']); $l->setRel('get'); $l->setAlt('Buscar'); $l->setPrompt('Buscar'); $l->setRender('link'); $i->addLink($l); $c->addItem($i); } $t = new Template(); $d = new Data(); $d->setName('name'); $d->setValue(null); $d->setPrompt('Nome do Usuario'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $d = new Data(); $d->setName('email'); $d->setValue(null); $d->setPrompt('Email do Usuario'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $d = new Data(); $d->setName('telefone'); $d->setValue(null); $d->setPrompt('Telefone do Usuario'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $queries = new Querie(); $queries->setHref($c->href); $queries->setData('field', '', true); $queries->setData('value', '', true); $c->addQueries($queries); $h->setCollection($c); } catch (Exception $ex) { $error = new Error(); $error->setCode(Response::INTERNALSERVERERROR); $error->setTitle('Internal Server Error'); $error->setDescription($ex); $c->setError($error); $h->setCollection($c); $response->code = Response::INTERNALSERVERERROR; $response->body = $h->getHypermedia($request->accept[10][0]); return $response; } $response->body = $h->getHypermedia($request->accept[10][0]); return $response; }
} if (right_bottom) { right_bottom.location.href = "' . $sess->url('main.php?area=workflow&frame=4') . '"; } </script>'; } $ui = new UI_Menu(); $workflows->select("idclient = '{$client}' AND idlang = '{$lang}'"); while ($workflow = $workflows->next()) { $wfid = $workflow->getField("idworkflow"); $wfname = $workflow->getField("name"); $wfdescription = $workflow->getField("description"); /* Create the link to show/edit the workflow */ $link = new Link(); $link->setMultiLink("workflow", "", "workflow_common", "workflow_show"); $link->setAlt($wfdescription); $link->setCustom("idworkflow", $wfid); $delTitle = i18n("Delete workflow", "workflow"); $delDescr = sprintf(i18n("Do you really want to delete the following workflow:<br><br>%s<br>", "workflow"), $wfname); $delete = '<a title="' . $delTitle . '" href="javascript://" onclick="box.confirm(\'' . $delTitle . '\', \'' . $delDescr . '\', \'deleteWorkflow(\\\'' . $wfid . '\\\')\')"><img src="' . $cfg['path']['images'] . 'delete.gif" border="0" title="' . $delTitle . '" alt="' . $delTitle . '"></a>'; $ui->setTitle($wfid, $wfname); $ui->setLink($wfid, $link); $ui->setActions($wfid, 'delete', $delete); if ($wfid == $iIdMarked) { $ui->setExtra($wfid, 'id="marked" '); } } $content = $ui->render(false); $delScript = ' <script type="text/javascript">
/** * Retorna uma lista de grupos * * @license http://www.gnu.org/copyleft/gpl.html GPL * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) * @sponsor Caixa Econômica Federal * @author Adrino Coutinho da Silva. * @return Retorna uma lista de Contatos Dinâmicos, Grupos, Contatos Pessoais, Grupos Compartilhados e Contatos Compartilhados * @access public * */ function get($request) { $this->secured(); //verificar se a preferencia de contatos dinamicos nao esta ativada if (!$this->isEnabledDynamicContacts(Config::me("uidNumber"))) { $response = new Response($request); $this->createException($request, $response, Response::UNAUTHORIZED, 'Resource unauthorized', 'disabled dynamic contacts preference'); return $response; } $response = new Response($request); $response->addHeader('Content-type', 'aplication/json'); $response->code = Response::OK; $h = new Hypermedia(); $c = new Collection($request->resources, 'UserContactsResource'); try { $d = new Data(); $d->setName('User Contacts'); $d->setValue(null); $d->setPrompt('Contatos do usuário'); $d->setDataType(null); $d->setMaxLength(null); $d->setMinLength(null); $d->setRequired(null); $c->addData($d); //Recupera os contatos dinâmicos do usuario $dynamicContacts = Controller::find(array('concept' => 'dynamicContact'), false, array('filter' => array('=', 'owner', Config::me("uidNumber")), 'order' => array('number_of_messages', 'name', 'mail'), 'orderDesc' => array(true, false, false))); if ($dynamicContacts) { foreach ($dynamicContacts as $value) { $d = new Data(); $i = new Item($request->resources, 'DynamicContactsResource', $value['id']); $d->setName('name'); $d->setValue($value['name']); $d->setPrompt('Nome do Contato Recente'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('mail'); $d->setValue($value['mail']); $d->setPrompt('Email do Contato Recente'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('number_of_messages'); $d->setValue((int) $value['number_of_messages']); $d->setPrompt('Quantidade de mensagens enviadas'); $d->setDataType('integer'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(false); $i->addData($d); $d = new Data(); $d->setName('id'); $d->setValue($value['id']); $d->setPrompt('Id do contato dinamico'); $d->setDataType('integer'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(false); $i->addData($d); $l = new Link(); $l->setHref(''); $l->setRel('delete'); $l->setAlt('Remover'); $l->setPrompt('Remover'); $l->setRender('link'); $i->addLink($l); $l = new Link(); $l->setHref(''); $l->setRel('put'); $l->setAlt('Atualizar'); $l->setPrompt('Atualizar'); $l->setRender('link'); $i->addLink($l); $l = new Link(); $l->setHref('/dynamiccontact/' . $value['id']); $l->setRel('get'); $l->setAlt('Buscar'); $l->setPrompt('Buscar'); $l->setRender('link'); $i->addLink($l); $c->addItem($i); } } $idS = array(Config::me("uidNumber")); $acl = array(); //Recupera o uidNumber de todos os usuários que compartilham suas agendas com o usuário logado $shareds = Controller::service('PostgreSQL')->execResultSql('select acl_account as "uidNumber", acl_rights as "acl" from phpgw_acl where (acl_location = \'' . Config::me("uidNumber") . '\' AND acl_appname = \'contactcenter\' )'); if (!empty($shareds) && $shareds) { foreach ($shareds as $s) { array_push($idS, $s['uidNumber']); $acl[$s['uidNumber']] = $this->decodeAcl(decbin($s['acl'])); } } //Recupera os grupos do usuario $groups = Controller::find(array('concept' => 'contactGroup'), false, array('filter' => array('IN', 'user', $idS), 'order' => array('name'))); if ($groups) { foreach ($groups as $value) { if ($value['user'] == Config::me("uidNumber") || $acl[$value['user']]['read']) { $i = new Item($request->resources, $value['user'] == Config::me("uidNumber") ? 'GroupsResource' : 'SharedGroupResource', $value['id']); $d = new Data(); $d->setName('id'); $d->setValue($value['id']); $d->setPrompt('Id do Grupo'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('owner'); $d->setValue($value['user']); $d->setPrompt('Id Dono do Grupo'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('name'); $d->setValue($value['name']); $d->setPrompt('Nome do Grupo'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('mail'); $d->setValue($value['email']); $d->setPrompt('Email do Grupo'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); if (Config::me("uidNumber") != $value['user']) { /* Descomentar ao implementar os métodos if ($acl[$value['user']]['delete']) { $l = new Link(); $l->setHref(''); $l->setRel('delete'); $l->setAlt('Remover'); $l->setPrompt('Remover'); $l->setRender('link'); $i->addLink($l); } if ($acl[$value['user']]['update']) { $l = new Link(); $l->setHref(''); $l->setRel('put'); $l->setAlt('Atualizar'); $l->setPrompt('Atualizar'); $l->setRender('link'); $i->addLink($l); } if ($acl[$value['user']]['write']) { $l = new Link(); $l->setHref(''); $l->setRel('post'); $l->setAlt('Criar'); $l->setPrompt('Criar novo'); $l->setRender('link'); $i->addLink($l); } */ $l = new Link(); $l->setHref('/sharedgroup/' . $value['id']); $l->setRel('get'); $l->setAlt('Buscar'); $l->setPrompt('Buscar'); $l->setRender('link'); $i->addLink($l); } else { /* Descomentar ao implementar métodos no recurso $l = new Link(); $l->setHref(''); $l->setRel('delete'); $l->setAlt('Remover'); $l->setPrompt('Remover'); $l->setRender('link'); $i->addLink($l); $l = new Link(); $l->setHref(''); $l->setRel('put'); $l->setAlt('Atualizar'); $l->setPrompt('Atualizar'); $l->setRender('link'); $i->addLink($l); */ $l = new Link(); $l->setHref('/group/' . $value['id']); $l->setRel('get'); $l->setAlt('Buscar'); $l->setPrompt('Buscar'); $l->setRender('link'); $i->addLink($l); } $c->addItem($i); } } } //Recupera os contatos pessoais do usuario $contacts = Controller::find(array('concept' => 'contact'), false, array('filter' => array('IN', 'user', $idS))); if ($contacts) { foreach ($contacts as $value) { if ($value['user'] == Config::me("uidNumber") || $acl[$value['user']]['read']) { $d = new Data(); $i = new Item($request->resources, $value['user'] == Config::me("uidNumber") ? 'PersonalContactResource' : 'SharedContactResource', $value['id']); $d->setName('id'); $d->setValue($value['id']); $d->setPrompt('Id do Contato'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('owner'); $d->setValue($value['user']); $d->setPrompt('Id Dono do Contato'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('name'); $d->setValue($value['name']); $d->setPrompt('Nome do Contato'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('mail'); $d->setValue(isset($value['email']) ? $value['email'] : null); $d->setPrompt('Email do Contato'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('telephone'); $d->setValue(isset($value['telephone']) ? $value['telephone'] : null); $d->setPrompt('Telefone do Contato'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); if (Config::me("uidNumber") != $value['user']) { $l = new Link(); $l->setHref('/sharedcontact/' . $value['id']); $l->setRel('get'); $l->setAlt('Buscar'); $l->setPrompt('Buscar'); $l->setRender('link'); $i->addLink($l); /* Descomentar ao criar recursos if ($acl[$value['user']]['delete']) { $l = new Link(); $l->setHref(''); $l->setRel('delete'); $l->setAlt('Remover'); $l->setPrompt('Remover'); $l->setRender('link'); $i->addLink($l); } if ($acl[$value['user']]['put']) { $l = new Link(); $l->setHref(''); $l->setRel('put'); $l->setAlt('Atualizar'); $l->setPrompt('Atualizar'); $l->setRender('link'); $i->addLink($l); } */ } else { /* Descomentar ao criar recursos $l = new Link(); $l->setHref(''); $l->setRel('delete'); $l->setAlt('Remover'); $l->setPrompt('Remover'); $l->setRender('link'); $i->addLink($l); $l = new Link(); $l->setHref(''); $l->setRel('put'); $l->setAlt('Atualizar'); $l->setPrompt('Atualizar'); $l->setRender('link'); $i->addLink($l); */ $l = new Link(); $l->setHref('/contact/' . $value['id']); $l->setRel('get'); $l->setAlt('Buscar'); $l->setPrompt('Buscar'); $l->setRender('link'); $i->addLink($l); } $c->addItem($i); } } } if (!$contacts && !$dynamicContacts && !$groups) { $this->createException($request, $response, Response::NOTFOUND, 'Bad request', 'Resource not found.'); return $response; } $t = new Template(); $d = new Data(); $d->setName('id'); $d->setValue(null); $d->setPrompt('Id do Grupo'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $d = new Data(); $d->setName('user'); $d->setValue(null); $d->setPrompt('Id Dono do Grupo'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $d = new Data(); $d->setName('name'); $d->setValue(null); $d->setPrompt('Nome do Grupo'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $c->setTemplate($t); $h->setCollection($c); $response->body = $h->getHypermedia($request->accept[10][0]); return $response; } catch (Exception $ex) { $this->createException($request, $response, Response::INTERNALSERVERERROR, 'Internal Server Error', $ex); return $response; } }
/** * Retorna uma lista de contatos recentes * * @license http://www.gnu.org/copyleft/gpl.html GPL * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) * @sponsor Caixa Econômica Federal * @author José Vicente Tezza Jr. * @return Retorna uma lista de contatos recentes * @access public * */ function get($request) { $this->secured(); $response = new Response($request); $response->addHeader('Content-type', 'aplication/json'); $response->code = Response::OK; $h = new Hypermedia(); $c = new Collection($request->resources, 'DynamicContactsResource'); try { $dynamicContacts = Controller::find(array('concept' => 'dynamicContact'), false, array('filter' => array('=', 'owner', Config::me("uidNumber")), 'order' => array('number_of_messages', 'name', 'mail'), 'orderDesc' => array(true, false, false))); //Se nao foi encontrado contatos na consulta if (!$dynamicContacts) { $this->createException($request, $response, Response::NOTFOUND, 'Bad request', 'Dynamic Contact not found.'); return $response; } $dynamicContacts = array_slice($dynamicContacts, 0, 50); foreach ($dynamicContacts as $value) { $d = new Data(); $i = new Item($request->resources, 'DynamicContactsResource', $value['id']); $d->setName('name'); $d->setValue($value['name']); $d->setPrompt('Nome do Contato Recente'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('mail'); $d->setValue($value['mail']); $d->setPrompt('Email do Contato Recente'); $d->setDataType('string'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(true); $i->addData($d); $d = new Data(); $d->setName('number_of_messages'); $d->setValue($value['number_of_messages']); $d->setPrompt('Quantidade de mensagens enviadas'); $d->setDataType('integer'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(false); $i->addData($d); $d = new Data(); $d->setName('id'); $d->setValue($value['id']); $d->setPrompt('Id do contato dinamico'); $d->setDataType('integer'); $d->setMaxLength('100'); $d->setMinLength(null); $d->setRequired(false); $i->addData($d); $l = new Link(); $l->setHref(''); $l->setRel('delete'); $l->setAlt('Remover'); $l->setPrompt('Remover'); $l->setRender('link'); $i->addLink($l); $l = new Link(); $l->setHref(''); $l->setRel('put'); $l->setAlt('Atualizar'); $l->setPrompt('Atualizar'); $l->setRender('link'); $i->addLink($l); $l = new Link(); $l->setHref('/dynamiccontact/' . $value['id']); $l->setRel('get'); $l->setAlt('Buscar'); $l->setPrompt('Buscar'); $l->setRender('link'); $i->addLink($l); $c->addItem($i); } $t = new Template(); $d = new Data(); $d->setName('name'); $d->setValue(null); $d->setPrompt('Nome do Contato Recente'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(false); $t->addData($d); $d = new Data(); $d->setName('mail'); $d->setValue(null); $d->setPrompt('Email do Contato Recente'); $d->setDataType('string'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(true); $t->addData($d); $d = new Data(); $d->setName('number_of_messages'); $d->setValue(null); $d->setPrompt('Quantidade de mensagens enviadas'); $d->setDataType('integer'); $d->setMaxLength(100); $d->setMinLength(null); $d->setRequired(false); $t->addData($d); $c->setTemplate($t); $h->setCollection($c); } catch (Exception $ex) { $this->createException($request, $response, Response::INTERNALSERVERERROR, 'Internal Server Error', $ex); return $response; } $response->body = $h->getHypermedia($request->accept[10][0]); return $response; }
function getWorkflowUsers($idworkflowitem) { global $idworkflow, $cfg; $ui = new UI_Menu(); $workflowusers = new WorkflowUserSequences(); $workflowusers->select("idworkflowitem = '{$idworkflowitem}'", "", "position ASC"); while ($workflowitem = $workflowusers->next()) { $pos = $workflowitem->get("position"); $iduser = $workflowitem->get("iduser"); $timelimit = $workflowitem->get("timelimit"); $timeunit = $workflowitem->get("timeunit"); $email = $workflowitem->get("emailnoti"); $escalation = $workflowitem->get("escalationnoti"); $timeunit = $workflowitem->get("timeunit"); $id = $workflowitem->get("idusersequence"); $moveup = new Link(); $moveup->setCLink("workflow_steps", 4, "workflow_user_up"); $moveup->setCustom("idworkflowitem", $idworkflowitem); $moveup->setCustom("idworkflow", $idworkflow); $moveup->setCustom("position", $pos); $moveup->setAlt(i18n("Move user up", "workflow")); #$moveup->setContent('<img border="0" style="padding-left: 2px" src="images/pfeil_hoch.gif">'); $moveup->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/no_verschieben.gif" . '">'); $movedown = new Link(); $movedown->setCLink("workflow_steps", 4, "workflow_user_down"); $movedown->setCustom("idworkflowitem", $idworkflowitem); $movedown->setCustom("idworkflow", $idworkflow); $movedown->setCustom("position", $pos); $movedown->setAlt(i18n("Move user down", "workflow")); $movedown->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/nu_verschieben.gif" . '">'); $deletestep = new Link(); $deletestep->setCLink("workflow_steps", 4, "workflow_user_delete"); $deletestep->setCustom("idworkflowitem", $idworkflowitem); $deletestep->setCustom("idworkflow", $idworkflow); $deletestep->setCustom("position", $pos); $deletestep->setCustom("idusersequence", $id); $deletestep->setAlt(i18n("Delete user", "workflow")); $deletestep->setContent('<img style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/workflow_step_delete.gif" . '">'); $title = "{$pos}. " . getUsers($id, $iduser); $title .= formGenerateField("text", "wftimelimit" . $id, $timelimit, 3, 6); $title .= getTimeUnitSelector($id, $timeunit); $altmail = i18n("Notify this user via E-Mail", "workflow"); $altnoti = i18n("Escalate to this user via E-Mail", "workflow"); $title .= formGenerateCheckbox("wfemailnoti[" . $id . "]", "1", $email) . '<label for="wfemailnoti[' . $id . ']1"><img alt="' . $altmail . '" title="' . $altmail . '" style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/workflow_email_noti.gif" . '"></label>'; $title .= formGenerateCheckbox("wfescalnoti[" . $id . "]", "1", $escalation) . '<label for="wfescalnoti[' . $id . ']1"><img alt="' . $altnoti . '" title="' . $altnoti . '" style="padding-left: 2px" border="0" src="' . $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/workflow_escal_noti.gif" . '"></label>'; $ui->setTitle($id, $title); $ui->setLink($id, NULL); if ($pos > 1) { $ui->setActions($id, "moveup", $moveup->render()); } else { $ui->setActions($id, "moveup", '<img style="padding-left: 2px" src="images/spacer.gif" width="15" height="1">'); } if ($pos < $workflowusers->count()) { $ui->setActions($id, "movedown", $movedown->render()); } else { $ui->setActions($id, "movedown", '<img style="padding-left: 2px" src="images/spacer.gif" width="15" height="1">'); } $ui->setActions($id, "delete", $deletestep->render()); $ui->setImage($id, $cfg["path"]["contenido_fullhtml"] . $cfg["path"]["plugins"] . "workflow/images/workflow_user.gif"); } $createstep = new Link(); $createstep->setCLink("workflow_steps", 4, "workflow_create_user"); $createstep->setCustom("idworkflow", $idworkflow); $createstep->setCustom("idworkflowitem", $idworkflowitem); $ui->setLink("spacer", NULL); $ui->setTitle("create", '<input class="text_medium" type="submit" name="adduser" value="' . i18n("Add User", "workflow") . '">'); $ui->setLink("create", NULL); $content = $ui->render(false); return $content; }