[6351] | 1 | <?php |
---|
| 2 | |
---|
| 3 | require_once('/home/tezza/expressoDFD/prototype/rest/hypermedia/hypermedia.php'); |
---|
| 4 | |
---|
[6357] | 5 | use prototype\api\Config as Config; |
---|
| 6 | |
---|
[6351] | 7 | class DynamicContactDeleteResource extends Resource{ |
---|
| 8 | |
---|
| 9 | /** |
---|
| 10 | * Busca os eventos contidos nas agendas assinas do usuário |
---|
| 11 | * |
---|
| 12 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
| 13 | * @author Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br) |
---|
| 14 | * @sponsor Caixa Econômica Federal |
---|
| 15 | * @author Adriano Coutinho da Silva |
---|
| 16 | * @author Adir Kuhn |
---|
| 17 | * @return Remove um resource do contato |
---|
| 18 | * @access public |
---|
| 19 | **/ |
---|
| 20 | function get($request) { |
---|
| 21 | try { |
---|
| 22 | |
---|
| 23 | $response = new Response($request); |
---|
| 24 | $response->addHeader('Content-type', 'aplication/json'); |
---|
| 25 | $this->secured(); |
---|
| 26 | $response->code = Response::OK; |
---|
| 27 | |
---|
| 28 | $dynamicContact = Controller::find(array('concept' => 'dynamicContact'), false, array('filter' => array('=', 'owner', Config::me("uidNumber")))); |
---|
| 29 | |
---|
| 30 | $h = new Hypermedia(); |
---|
| 31 | $c = new Collection($request->resources, 'DynamicContactsResource'); |
---|
| 32 | |
---|
| 33 | foreach($dynamicContact as $value){ |
---|
| 34 | $d = new Data(); |
---|
| 35 | $i = new Item($request->resources, 'DynamicContactResource', $value['id']); |
---|
| 36 | |
---|
| 37 | $d->setName('name'); |
---|
| 38 | $d->setValue($value['name']); |
---|
| 39 | $d->setPrompt('Nome do contato'); |
---|
| 40 | $d->setDataType('string'); |
---|
| 41 | $d->setMaxLength('100'); |
---|
| 42 | $d->setMinLength(null); |
---|
| 43 | $d->setRequired(false); |
---|
| 44 | |
---|
| 45 | $i->addData($d); |
---|
| 46 | |
---|
| 47 | $d->setName('email'); |
---|
| 48 | $d->setValue($value['mail']); |
---|
| 49 | $d->setPrompt('Email do contato'); |
---|
| 50 | $d->setDataType('string'); |
---|
| 51 | $d->setMaxLength('100'); |
---|
| 52 | $d->setMinLength(null); |
---|
| 53 | $d->setRequired(true); |
---|
| 54 | |
---|
| 55 | $i->addData($d); |
---|
| 56 | $l = new Link(); |
---|
| 57 | |
---|
| 58 | $l->setHref($i->getHref()); |
---|
| 59 | $l->setRel('delete'); |
---|
| 60 | $l->setAlt('Remover'); |
---|
| 61 | $l->setPrompt('Remover'); |
---|
| 62 | $l->setRender('link'); |
---|
| 63 | |
---|
| 64 | $i->addLink($l); |
---|
| 65 | |
---|
| 66 | $l->setHref($i->getHref()); |
---|
| 67 | $l->setRel('put'); |
---|
| 68 | $l->setAlt('Atualizar'); |
---|
| 69 | $l->setPrompt('Atualizar'); |
---|
| 70 | $l->setRender('link'); |
---|
| 71 | |
---|
| 72 | $i->addLink($l); |
---|
| 73 | |
---|
| 74 | $l->setHref($i->getHref()); |
---|
| 75 | $l->setRel('get'); |
---|
| 76 | $l->setAlt('Buscar'); |
---|
| 77 | $l->setPrompt('Buscar'); |
---|
| 78 | $l->setRender('link'); |
---|
| 79 | |
---|
| 80 | $i->addLink($l); |
---|
| 81 | $c->addItem($i); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | $t = new Template(); |
---|
| 85 | $d = new Data(); |
---|
| 86 | |
---|
| 87 | $d->setName('name'); |
---|
| 88 | $d->setValue(null); |
---|
| 89 | $d->setPrompt('Nome do contato'); |
---|
| 90 | $d->setDataType('string'); |
---|
| 91 | $d->setMaxLength(100); |
---|
| 92 | $d->setMinLength(null); |
---|
| 93 | $d->setRequired(false); |
---|
| 94 | |
---|
| 95 | $t->addData($d); |
---|
| 96 | $d = new Data(); |
---|
| 97 | |
---|
| 98 | $d->setName('email'); |
---|
| 99 | $d->setValue(null); |
---|
| 100 | $d->setPrompt('Email do contato'); |
---|
| 101 | $d->setDataType('string'); |
---|
| 102 | $d->setMaxLength(100); |
---|
| 103 | $d->setMinLength(null); |
---|
| 104 | $d->setRequired(true); |
---|
| 105 | |
---|
| 106 | $t->addData($d); |
---|
| 107 | |
---|
| 108 | $c->setTemplate($t); |
---|
| 109 | $d = new Data(); |
---|
| 110 | |
---|
| 111 | $d->setName('Dynamic Contacts'); |
---|
| 112 | $d->setValue(null); |
---|
| 113 | $d->setPrompt('Contatos Dinâmicos'); |
---|
| 114 | $d->setDataType(null); |
---|
| 115 | $d->setMaxLength(null); |
---|
| 116 | $d->setMinLength(null); |
---|
| 117 | $d->setRequired(null); |
---|
| 118 | |
---|
| 119 | $c->setData($d); |
---|
| 120 | |
---|
| 121 | $h->setCollection($c); |
---|
| 122 | |
---|
| 123 | } catch (Exception $ex){ |
---|
| 124 | $response->code = Response::INTERNALSERVERERROR; |
---|
| 125 | $error = array( |
---|
| 126 | 'code' => '500', |
---|
| 127 | 'title' => 'Internal Server Error', |
---|
| 128 | 'description' => $ex); |
---|
| 129 | return $response; |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | $response->body = $h->getHypermeida($request->accept[10][0]); |
---|
| 133 | return $response; |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | } |
---|
| 137 | ?> |
---|