Beispiel #1
0
 static function load_tpl(&$data, $file)
 {
     include_once __DIR__ . '/../library/fileDuck/FileDuck.php';
     $config = array();
     $config['lang'] = 'pt_BR';
     $sql = "SELECT * FROM phpgw_preferences where preference_app = 'common' AND preference_owner IN ( '-2' , '-1' , " . Config::me('uidNumber') . " ) ORDER BY preference_owner";
     $preferences = Controller::service('PostgreSQL')->execResultSql($sql);
     foreach ($preferences as $preference) {
         $values = unserialize($preference['preference_value']);
         if (isset($values['lang'])) {
             $config['lang'] = $values['lang'];
         }
     }
     $config['provider'] = 'expresso';
     $config['YUICompressor'] = false;
     $configProvider = array();
     $configProvider['module'] = 'expressoCalendar';
     if (preg_match('/\\/modules\\/([a-z\\_\\-]+)\\//i', $file, $matches)) {
         $moduleMap = parse_ini_file(__DIR__ . "/../config/moduleMap.ini", true);
         $configProvider['module'] = isset($moduleMap[$matches[1]]) ? $moduleMap[$matches[1]] : 'phpgwapi';
     }
     $fileDuck = new FileDuck($config, $configProvider);
     $fileDuck->add($file, 'ISO-8859-1');
     $tpl = $fileDuck->renderContent();
     foreach ($data as $i => $v) {
         $tpl = str_replace('[' . $i . ']', $v, $tpl);
     }
     return $tpl;
 }
 public function addVerifyOwnerFilter(&$uri, &$params, &$criteria, $original)
 {
     $ownerFilter = array('=', 'uid', Config::me('uidNumber'));
     if (isset($criteria['filter']) && $criteria['filter'] != NULL && count($criteria['filter']) != 0) {
         $criteria['filter'] = array('AND', $criteria['filter'], $ownerFilter);
     } else {
         $criteria['filter'] = $ownerFilter;
     }
 }
Beispiel #3
0
 public function read($uri, $justthese = false)
 {
     $map = Config::get($uri['concept'], 'OpenLDAP.mapping');
     if ($justthese === false || $justthese === null) {
         $sr = ldap_search($this->con, $this->config['context'], '(' . $map['id'] . '=' . $uri['id'] . ')');
     } else {
         $sr = ldap_search($this->con, $this->config['context'], '(' . $map['id'] . '=' . $uri['id'] . ')', self::parseJustthese($justthese, $map));
     }
     if (!$sr) {
         return false;
     }
     $return = self::_formatEntries(ldap_get_entries($this->con, $sr), $map);
     return isset($return[0]) ? $return[0] : array();
 }
 /**
  * Retorna todos os contatos que o usario possui para usar na busca dinamica.
  * @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()) {
         $response = new Response($request);
         $response->addHeader('Content-type', 'aplication/json');
         $response->code = Response::UNAUTHORIZED;
         $response->body = 'disabled dynamic contacts preference';
         return $response;
     }
     $catalog = new CatalogDBMapping();
     $contactsUser = $catalog->allContactsUser(Config::me("uidNumber"));
     $response = new Response($request);
     $response->addHeader('Content-type', 'aplication/json');
     $response->code = Response::OK;
     $response->body = json_encode($contactsUser);
     return $response;
 }
Beispiel #5
0
 static function importCollection($url, $calendar)
 {
     ob_start();
     require_once ROOTPATH . '/plugins/davicalCliente/caldav-client-v2.php';
     $cal = new CalDAVClient(Config::service('CalDAV', 'url') . '/', Config::me('uid'), Config::me('password'));
     $events = $cal->GetCollectionETags($url);
     $args = array();
     foreach ($events as $ie => $ve) {
         $cal->DoGETRequest($ie);
         $sync = Controller::parse(array('service' => 'iCal'), $cal->GetResponseBody(), array('calendar' => $calendar, 'owner' => Config::me('uidNumber')));
         if (is_array($sync)) {
             $args = array_merge($args, $sync);
         }
     }
     include ROOTPATH . '/Sync.php';
     ob_end_clean();
 }
Beispiel #6
0
$target = gmdate('U') - 300 . '000';
$parts = Controller::service('PostgreSQL')->execSql('SELECT part.user_info_id as "user", co.id as "schedulable", co.type_id as "type", co.allDay as "allDay" ,co.dtend as "endTime", co.dtstart as "startTime", co.summary as "summary", co.tzid as "timezone", co.location as "location", al.id as "id" FROM calendar_object as co INNER JOIN calendar_alarm al ON co.id = al.object_id JOIN calendar_participant part  ON part.id = al.participant_id LEFT JOIN calendar_repeat rep ON  rep.object_id = co.id  LEFT JOIN calendar_repeat_occurrence occ ON occ.repeat_id = rep.id WHERE ( al.action_id = \'' . ALARM_MAIL . '\' AND al.sent = \'0\' AND CASE WHEN occ.occurrence > 0 THEN occ.occurrence - al.alarm_offset ELSE co.dtstart - al.alarm_offset END BETWEEN \'' . $target . '\' AND \'' . ($target + 360000) . '\') ');
if (!is_array($parts)) {
    return;
}
$ids = array();
foreach ($parts as $i => $part) {
    ///Montando lista de participantes
    $users = Controller::find(array('concept' => 'participant'), array('user', 'id', 'isExternal'), array('filter' => array('=', 'schedulable', $part['schedulable']), 'deepness' => 1));
    $attList = array();
    foreach ($users as $user) {
        if ($part['user'] === $user['user']['id']) {
            $part['mail'] = $user['user']['mail'];
        }
        $attList[] = $user['user']['name'];
    }
    $timezone = new DateTimeZone('UTC');
    $sTime = new DateTime('@' . (int) ($part['startTime'] / 1000), $timezone);
    $eTime = new DateTime('@' . (int) ($part['endTime'] / 1000), $timezone);
    $timezone = $part['timezone'];
    $sTime->setTimezone(new DateTimeZone($part['timezone']));
    $eTime->setTimezone(new DateTimeZone($part['timezone']));
    $data = array('startDate' => date_format($sTime, 'd/m/Y'), 'startTime' => $part['allDay'] ? '' : date_format($sTime, 'H:i'), 'endDate' => date_format($eTime, 'd/m/Y'), 'endTime' => $part['allDay'] ? '' : date_format($eTime, 'H:i'), 'eventTitle' => $part['summary'], 'eventLocation' => $part['location'], 'timezone' => $timezone, 'participants' => '<UL> <LI> ' . implode('<LI></LI> ', $attList) . '</LI> </UL>');
    Controller::create(array('service' => 'SMTP'), array('body' => parseTPL::load_tpl($data, ROOTPATH . '/modules/calendar/templates/' . ($parts['type'] == '1' ? 'notify_alarm_body.tpl' : 'notify_alarm_body_task.tpl')), 'isHtml' => true, 'subject' => 'Alarme de Calendario', 'from' => $part['mail'], 'to' => $part['mail']));
    Config::regSet('noAlarm', TRUE);
    //Evita o envio de notificação ?????
    $ids[] = $part['id'];
}
if (!empty($ids)) {
    Controller::update(array('concept' => 'alarm'), array('sent' => '1'), array('filter' => array('IN', 'id', $ids)));
}
Beispiel #7
0
 private function parseCondition($condition)
 {
     $tables = array();
     $conditions = '';
     $matches = array();
     if (preg_match_all('/\\s*(AND|^)\\s*([a-z]+)\\.([a-z]+)\\s+\\=\\s+([a-z]+)\\.([a-z]+)(\\s|$)+/i', $condition, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $i => $v) {
             if (!isset($this->maps[$v[2]]) || !isset($this->tables[$v[2]])) {
                 $this->maps[$v[2]] = Config::get($v[2], 'MySQL.mapping');
                 $this->tables[$v[2]] = Config::get($v[2], 'MySQL.concept');
             }
             if (!isset($this->maps[$v[4]]) || !isset($this->tables[$v[4]])) {
                 $this->maps[$v[4]] = Config::get($v[4], 'MySQL.mapping');
                 $this->tables[$v[4]] = Config::get($v[4], 'MySQL.concept');
             }
             if (isset($this->maps[$v[2]][$v[3]]) && isset($this->maps[$v[4]][$v[5]])) {
                 $conditions .= ' ' . $v[1] . ' ' . $this->tables[$v[2]] . '.' . $this->maps[$v[2]][$v[3]] . ' = ' . $this->tables[$v[4]] . '.' . $this->maps[$v[4]][$v[5]];
             } else {
                 continue;
             }
             if (!in_array($this->tables[$v[2]], $tables)) {
                 $tables[] = $this->tables[$v[2]];
             }
             if (!in_array($this->tables[$v[4]], $tables)) {
                 $tables[] = $this->tables[$v[4]];
             }
         }
     }
     if (preg_match_all('/\\s*(AND|OR|^)\\s*([a-z]+)\\.([a-z]+)\\s+([\\=\\>\\<\\!]+|like)+\\s+([a-z0-9\\/\\+\\=]+)(\\s|$)+/i', $condition, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $i => $v) {
             if (!isset($this->maps[$v[2]]) || !isset($this->tables[$v[2]])) {
                 $this->maps[$v[2]] = Config::get($v[2], 'MySQL.mapping');
                 $this->tables[$v[2]] = Config::get($v[2], 'MySQL.concept');
             }
             if (isset($this->maps[$v[2]][$v[3]])) {
                 $conditions .= ' ' . $v[1] . ' ' . $this->tables[$v[2]] . '.' . $this->maps[$v[2]][$v[3]] . ' ' . $v[4] . ' \'' . mysql_real_escape_string(base64_decode($v[5])) . '\'';
             } else {
                 continue;
             }
             if (!in_array($this->tables[$v[2]], $tables)) {
                 $tables[] = $this->tables[$v[2]];
             }
         }
     }
     return count($tables) > 0 && count($conditions) > 0 ? array('tables' => $tables, 'conditions' => $conditions) : '';
 }
 /**
  * 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;
     }
 }
 /**
  * Salva 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 a uri do contato recente
  * @access     public
  * */
 function post($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;
     }
     if (count($_POST) == 0) {
         $response = new Response($request);
         $response->code = Response::INTERNALSERVERERROR;
         return $response;
     }
     //recuperar os atributos definidos no conceito 'user'
     $map = Config::get('dynamicContact', 'PostgreSQL.mapping');
     $params = array();
     foreach ($_POST as $key => $value) {
         if (!isset($map[$key]) || $key == 'id' || $key == 'timestamp' || $key == 'number_of_messages') {
             continue;
         }
         $params[$key] = $value;
     }
     if (count($params) == 0) {
         $response = new Response($request);
         $response->code = Response::INTERNALSERVERERROR;
         return $response;
     }
     $response = new Response($request);
     $response->addHeader('Content-type', 'aplication/json');
     $response->code = Response::CREATED;
     //completar os atributos
     $params['owner'] = Config::me("uidNumber");
     $params['number_of_messages'] = '1';
     $params['timestamp'] = time();
     try {
         //verificar o limite maximo de contatos dinamicos nas preferencias do administrador
         $sql = "SELECT config_value " . "FROM phpgw_config " . "WHERE config_app = 'expressoMail' " . "AND config_name = 'expressoMail_Number_of_dynamic_contacts'";
         $numberOfMessages = Controller::service('PostgreSQL')->execResultSql($sql, true);
         $numberOfMessages = count($numberOfMessages) > 0 ? (int) $numberOfMessages['config_value'] : 0;
         //realizar busca de contatos dinamicos ordenados pela data de utilizacao
         $dynamicContacts = Controller::find(array('concept' => 'dynamicContact'), false, array('filter' => array('=', 'owner', Config::me("uidNumber")), 'order' => array('timestamp')));
         $numberOfDynamicContacts = $dynamicContacts !== false ? count($dynamicContacts) : 0;
         //se a quantidade de contatos dinamicos de usuario exceder o limite maximo definido nas preferencias do administrador,
         //remover o contato dinamico mais antigo
         if ($numberOfMessages > 0 && $numberOfDynamicContacts >= $numberOfMessages) {
             $id = $dynamicContacts[0]['id'];
             $delete = Controller::delete(array('concept' => 'dynamicContact', 'id' => $id));
             if (!$delete) {
                 $this->createException($request, $response, Response::INTERNALSERVERERROR, 'Internal Server Error', Controller::service('PostgreSQL')->error);
                 return $response;
             }
         }
         //inserir o novo contato dinamico
         $create = Controller::create(array('concept' => 'dynamicContact'), $params);
         if (!$create) {
             throw new Exception(Controller::service('PostgreSQL')->error);
         }
     } catch (Exception $ex) {
         $response->code = Response::INTERNALSERVERERROR;
         return $response;
     }
     $response->body = json_encode(null);
     return $response;
 }
Beispiel #10
0
 public function securityOwner(&$uri, &$params, &$criteria, $original)
 {
     $criteria['filter'] = isset($criteria['filter']) ? array('AND', $criteria['filter'], array('=', 'owner', Config::me('uidNumber'))) : array('=', 'owner', Config::me('uidNumber'));
 }
 /**
  * Remove 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. 
  * @access     public
  * */
 function delete($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::NOCONTENT;
     try {
         //Verifica se o recurso existe
         $dinamicContact = Controller::read(array('concept' => 'dynamicContact', 'id' => $id));
         //Se existe o recurso
         if ($dinamicContact) {
             $delete = Controller::delete(array('concept' => 'dynamicContact', 'id' => $id));
             if (!$delete) {
                 $this->createException($request, $response, Response::INTERNALSERVERERROR, 'Internal Server Error', Controller::service('PostgreSQL')->error);
                 return $response;
             }
         } else {
             $this->createException($request, $response, Response::NOTFOUND, 'Bad request', 'Invalid data');
             return $response;
         }
     } catch (Exception $ex) {
         $this->createException($request, $response, Response::INTERNALSERVERERROR, 'Internal Server Error', 'Internal Server Error');
         return $response;
     }
     $response->body = json_encode(null);
     return $response;
 }
 /**
  * Retorna um contato compartilhado 
  *
  * @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 Compartilhado
  * @access     public
  * */
 function get($request, $id)
 {
     $this->secured();
     $response = new Response($request);
     $response->addHeader('Content-type', 'aplication/json');
     $response->code = Response::OK;
     $h = new Hypermedia();
     $c = new Collection($request->resources, 'SharedGroupResource');
     try {
         //Recupera o contato
         $contact = Controller::find(array('concept' => 'contact'), false, array('filter' => array('=', 'id', $id)));
         if (!$contact) {
             $this->createException($request, $response, Response::NOTFOUND, 'Bad request', 'Resource not found.');
             return $response;
         }
         //Proprietario do contato
         $ownerId = $contact[0]['user'];
         $idS = array(Config::me("uidNumber"));
         $acl = array();
         //Recupera o uidNumber do usuário que compartilhou o grupo com o usuário logado
         $sql = 'SELECT acl_account as "uidNumber", acl_rights as "acl" ' . 'FROM phpgw_acl ' . 'WHERE (acl_location =   \'' . Config::me("uidNumber") . '\' AND acl_appname =  \'contactcenter\' AND acl_account = \'' . $ownerId . '\')';
         $shareds = Controller::service('PostgreSQL')->execResultSql($sql);
         //Verifica o acesso definido para o usuario logado
         $flagContact = false;
         if (!empty($shareds) && $shareds) {
             foreach ($shareds as $s) {
                 array_push($idS, $s['uidNumber']);
                 $acl[$s['uidNumber']] = $this->decodeAcl(decbin($s['acl']));
                 //verifica se o proprietario do contato habilitou o acesso de leitura para o usuario logado
                 if ($s['uidNumber'] == $ownerId && $acl[$s['uidNumber']]['read']) {
                     $flagContact = true;
                 }
             }
         }
         //Se o contato nao esta compartilhado
         if (!$flagContact) {
             $this->createException($request, $response, Response::UNAUTHORIZED, 'unauthorized', 'Resource unauthorized.');
             return $response;
         }
         //Obtem informacoes do proprietario do contato
         $userOwner = Controller::read(array('concept' => 'user', 'service' => 'OpenLDAP'), false, array('filter' => array('=', 'id', $ownerId), 'notExternal' => true));
         if (is_array($userOwner)) {
             $userOwner = $userOwner[0];
         }
         $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);
         $d = new Data();
         $d->setName('name');
         $d->setValue($contact[0]['name']);
         $d->setPrompt('Nome do Contato');
         $d->setDataType('string');
         $d->setMaxLength('100');
         $d->setMinLength(null);
         $d->setRequired(true);
         $c->addData($d);
         $d = new Data();
         $d->setName('email');
         $d->setValue($contact[0]['email']);
         $d->setPrompt('Email do Contato');
         $d->setDataType('string');
         $d->setMaxLength('100');
         $d->setMinLength(null);
         $d->setRequired(true);
         $c->addData($d);
         $d = new Data();
         $d->setName('telephone');
         $d->setValue($contact[0]['telephone']);
         $d->setPrompt('Telefone do Contato');
         $d->setDataType('string');
         $d->setMaxLength('100');
         $d->setMinLength(null);
         $d->setRequired(true);
         $c->addData($d);
         $d = new Data();
         $d->setName('ownerId');
         $d->setValue($userOwner['id']);
         $d->setPrompt('Atributo UID (LDAP)');
         $d->setDataType('string');
         $d->setMaxLength(100);
         $d->setMinLength(null);
         $d->setRequired(true);
         $c->addData($d);
         $d = new Data();
         $d->setName('ownerName');
         $d->setValue($userOwner['name']);
         $d->setPrompt('Atributo cn (LDAP)');
         $d->setDataType('string');
         $d->setMaxLength(100);
         $d->setMinLength(null);
         $d->setRequired(true);
         $c->addData($d);
         //Define os link baseado nas permissoes de acesso
         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);
                                 }
             
                                 if($acl[$value['user']]['read']){
                                       $l = new Link();
                                       $l->setHref('');
                                       $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('');
                                 $l->setRel('get');
                                 $l->setAlt('Buscar');
                                 $l->setPrompt('Buscar');
                                 $l->setRender('link');
             
                                 $i->addLink($l);
                                 */
         }
         $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;
 }
Beispiel #13
0
 function secured()
 {
     try {
         /* 
         		$oauth = new OAuth2(new OAuth2StorageUserCredential());
         		$token = $oauth->getBearerToken();
         		$oauth->verifyAccessToken($token);
         */
         if (!Config::me('uidNumber')) {
             throw new ResponseException('Session experired.', Response::UNAUTHORIZED);
         }
     } catch (OAuth2ServerException $oauthError) {
         $oauthError->sendHttpResponse();
     }
 }
Beispiel #14
0
 public function validateNumberSlots(&$uri, &$params, &$criteria, $original)
 {
     $used = Controller::read(array('concept' => 'label', 'id' => '1'), array('id'), array('uid' => Config::me('uidNumber')));
     if (!isset($used['id'])) {
         $params['id'] = '1';
         return;
     }
     $max = Controller::service('PostgreSQL')->execSql("SELECT config_value as value FROM phpgw_config where config_app = 'expressoMail' and config_name = 'expressoMail_limit_labels' LIMIT 1");
     $total = Controller::service('PostgreSQL')->execSql("SELECT count(id) as value FROM expressomail_label WHERE user_id = " . Config::me('uidNumber'));
     if ($total >= $max) {
         throw new Exception('#LabelSlotError');
     }
     $slot = Controller::service('PostgreSQL')->execSql('SELECT label.slot + 1 as id FROM expressomail_label as label, phpgw_config as config WHERE label.user_id = ' . Config::me('uidNumber') . ' AND config.config_name = \'expressoMail_limit_labels\' AND label.slot <= config.config_value::integer AND ( SELECT count(slot) FROM expressomail_label WHERE slot = label.slot + 1 AND user_id = ' . Config::me('uidNumber') . ' ) = 0 limit 1', true);
     if (empty($slot)) {
         throw new Exception('#LabelSlotError');
     }
     $params['id'] = $slot['id'];
 }
Beispiel #15
0
<?php

require_once dirname(__FILE__) . '/api/controller.php';
use prototype\api\Config;
$uidNumber = Config::me('uidNumber') ? Config::me('uidNumber') : $_SESSION['phpgw_info']['expressomail']['user']['account_id'];
$me = Controller::read(array('concept' => 'user', 'service' => 'OpenLDAP', 'id' => $uidNumber));
$sql = "SELECT * FROM phpgw_preferences where preference_app = 'common' AND preference_owner IN ( '-2' , '-1' , {$me['id']} ) ORDER BY preference_owner DESC";
$preferences = Controller::service('PostgreSQL')->execResultSql($sql);
foreach ($preferences as $preference) {
    $values = unserialize($preference['preference_value']);
    if (isset($values['lang'])) {
        $me['lang'] = $values['lang'];
    }
}
echo json_encode($me);
Beispiel #16
0
 public static function wallet($serviceName)
 {
     if (!isset(self::$wallet)) {
         //// Hack //// TODO: passar o init da sessão no login do expresso
         Config::init();
         if (isset($_SESSION['wallet'])) {
             self::$wallet = $_SESSION['wallet'];
         }
         /////////////
     }
     return isset(self::$wallet[$serviceName]) ? self::$wallet[$serviceName] : false;
 }
Beispiel #17
0
 static function findPersonalContacts($search_for)
 {
     $query = 'select' . ' C.id_connection,' . ' A.id_contact,' . ' A.names_ordered,' . ' A.alias,' . ' A.birthdate,' . ' A.sex,' . ' A.pgp_key,' . ' A.notes,' . ' A.web_page,' . ' A.corporate_name,' . ' A.job_title,' . ' A.department,' . ' C.connection_name,' . ' C.connection_value,' . ' B.id_typeof_contact_connection,' . ' phpgw_cc_contact_addrs.id_typeof_contact_address,' . ' phpgw_cc_addresses.address1,' . ' phpgw_cc_addresses.address2,' . ' phpgw_cc_addresses.complement,' . ' phpgw_cc_addresses.postal_code,' . ' phpgw_cc_city.city_name,' . ' phpgw_cc_state.state_name,' . ' phpgw_cc_addresses.id_country';
     $query .= ' from' . ' phpgw_cc_contact A' . ' inner join phpgw_cc_contact_conns B on ( A.id_contact = B.id_contact )' . ' inner join phpgw_cc_connections C on ( B.id_connection = C.id_connection )' . ' left join phpgw_cc_contact_addrs on ( A.id_contact = phpgw_cc_contact_addrs.id_contact )' . ' left join phpgw_cc_addresses on ( phpgw_cc_contact_addrs.id_address = phpgw_cc_addresses.id_address )' . ' left join phpgw_cc_city on ( phpgw_cc_addresses.id_city = phpgw_cc_city.id_city )' . ' left join phpgw_cc_state on ( phpgw_cc_addresses.id_state = phpgw_cc_state.id_state)';
     $query .= ' where ' . 'A.id_owner=' . Config::me('uidNumber') . ' and lower(translate(names_ordered, \'áàâãäéèêëíìïóòôõöúùûüÁÀÂÃÄÉÈÊËÍÌÏÓÒÔÕÖÚÙÛÜçÇñÑ\',\'aaaaaeeeeiiiooooouuuuAAAAAEEEEIIIOOOOOUUUUcCnN\'))' . ' LIKE lower(translate(\'%' . $search_for . '%\', \'áàâãäéèêëíìïóòôõöúùûüÁÀÂÃÄÉÈÊËÍÌÏÓÒÔÕÖÚÙÛÜçÇñÑ\',\'aaaaaeeeeiiiooooouuuuAAAAAEEEEIIIOOOOOUUUUcCnN\'))';
     //Se não existir parametro na busca, limita os usuarios no resultado da pesquisa.
     if (!$search_for) {
         $query .= 'LIMIT 11';
     }
     $r = Controller::service('PostgreSQL')->execResultSql($query);
     $all_contacts = array();
     foreach ($r as $i => $object) {
         if (!array_key_exists($object['id_contact'], $all_contacts)) {
             $all_contacts[$object['id_contact']] = array('connection_value' => '', 'telephonenumber' => '', 'mobile' => '', 'cn' => '', 'id_contact' => '', 'id_connection' => '', 'alias' => '', 'birthdate' => '', 'sex' => '', 'pgp_key' => '', 'notes' => '', 'web_page' => '', 'corporate_name' => '', 'job_title' => '', 'department' => '', 'mail' => '', 'aternative-mail' => '', 'business-phone' => '', 'business-address' => '', 'business-complement' => '', 'business-postal_code' => '', 'business-city_name' => '', 'business-state_name' => '', 'business-id_country' => '', 'business-fax' => '', 'business-pager' => '', 'business-mobile' => '', 'business-address-2' => '', 'home-phone' => '', 'home-address' => '', 'home-complement' => '', 'home-postal_code' => '', 'home-city_name' => '', 'home-state_name' => '', 'home-fax' => '', 'home-pager' => '', 'home-address-2' => '');
         }
         switch ($object['id_typeof_contact_connection']) {
             case 1:
                 $all_contacts[$object['id_contact']]['connection_value'] = $object['connection_value'];
                 switch (strtolower($object['connection_name'])) {
                     case 'alternativo':
                         $all_contacts[$object['id_contact']]['alternative-mail'] = $object['connection_value'];
                         break;
                     case 'principal':
                         $all_contacts[$object['id_contact']]['mail'] = $object['connection_value'];
                         break;
                 }
                 break;
             case 2:
                 $all_contacts[$object['id_contact']]['telephonenumber'] = $object['connection_value'];
                 switch (strtolower($object['connection_name'])) {
                     case 'casa':
                         $all_contacts[$object['id_contact']]['home-phone'] = $object['connection_value'];
                         break;
                     case 'celular':
                         $all_contacts[$object['id_contact']]['mobile'] = $object['connection_value'];
                         break;
                     case 'trabalho':
                         $all_contacts[$object['id_contact']]['business-phone'] = $object['connection_value'];
                         break;
                     case 'fax':
                         $all_contacts[$object['id_contact']]['home-fax'] = $object['connection_value'];
                         break;
                     case 'pager':
                         $all_contacts[$object['id_contact']]['home-pager'] = $object['connection_value'];
                         break;
                     case 'celular corporativo':
                         $all_contacts[$object['id_contact']]['business-mobile'] = $object['connection_value'];
                         break;
                     case 'pager corporativo':
                         $all_contacts[$object['id_contact']]['business-pager'] = $object['connection_value'];
                         break;
                     case 'fax corporativo':
                         $all_contacts[$object['id_contact']]['business-fax'] = $object['connection_value'];
                         break;
                 }
                 break;
         }
         $all_contacts[$object['id_contact']]['cn'] = utf8_encode($object['names_ordered']);
         $all_contacts[$object['id_contact']]['id_contact'] = $object['id_contact'];
         $all_contacts[$object['id_contact']]['id_connection'] = $object['id_connection'];
         $all_contacts[$object['id_contact']]['alias'] = $object['alias'];
         $all_contacts[$object['id_contact']]['birthdate'] = $object['birthdate'];
         $all_contacts[$object['id_contact']]['sex'] = $object['sex'];
         $all_contacts[$object['id_contact']]['pgp_key'] = $object['pgp_key'];
         $all_contacts[$object['id_contact']]['notes'] = $object['notes'];
         $all_contacts[$object['id_contact']]['web_page'] = $object['web_page'];
         $all_contacts[$object['id_contact']]['corporate_name'] = $object['corporate_name'];
         $all_contacts[$object['id_contact']]['job_title'] = $object['job_title'];
         $all_contacts[$object['id_contact']]['department'] = $object['department'];
         switch ($object['id_typeof_contact_address']) {
             case 1:
                 $all_contacts[$object['id_contact']]['business-address'] = $object['address1'];
                 $all_contacts[$object['id_contact']]['business-address-2'] = $object['address2'];
                 $all_contacts[$object['id_contact']]['business-complement'] = $object['complement'];
                 $all_contacts[$object['id_contact']]['business-postal_code'] = $object['postal_code'];
                 $all_contacts[$object['id_contact']]['business-city_name'] = $object['city_name'];
                 $all_contacts[$object['id_contact']]['business-state_name'] = $object['state_name'];
                 $all_contacts[$object['id_contact']]['business-id_country'] = $object['id_country'];
                 break;
             case 2:
                 $all_contacts[$object['id_contact']]['home-address'] = $object['address1'];
                 $all_contacts[$object['id_contact']]['home-address-2'] = $object['address2'];
                 $all_contacts[$object['id_contact']]['home-complement'] = $object['complement'];
                 $all_contacts[$object['id_contact']]['home-postal_code'] = $object['postal_code'];
                 $all_contacts[$object['id_contact']]['home-city_name'] = $object['city_name'];
                 $all_contacts[$object['id_contact']]['home-state_name'] = $object['state_name'];
                 $all_contacts[$object['id_contact']]['home-id_country'] = $object['id_country'];
                 break;
         }
     }
     $all = array_values($all_contacts);
     $result = array();
     foreach ($all as $i => $v) {
         if (!$v['mail']) {
             continue;
         }
         $tmp = array();
         $tmp['mail'] = $v['mail'];
         $tmp['name'] = $v['cn'];
         $tmp['isExternal'] = '1';
         $result[] = $tmp;
     }
     return $result;
 }
Beispiel #18
0
 /**
  * Faz um diff do update se ouve realmente uma alteração envia um email a todos os participants
  *
  * @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     Cristiano Corrêa Schmidt
  * @return     void
  * @access     public
  */
 public function updateEvent(&$uri, $params, &$criteria, $original)
 {
     $schedulableOld = Controller::read(array('concept' => 'schedulable', 'id' => $uri['id']), null, array('deepness' => '2'));
     $schedulable = $schedulableOld;
     $alt = false;
     foreach ($params as $i => $v) {
         //Verifica se ouve alteração no evento
         if (isset($schedulableOld[$i]) && $schedulableOld[$i] != $v && $i != 'participants') {
             $schedulable[$i] = $v;
             $alt = true;
         }
     }
     if ($alt === true && Config::regGet('noAlarm') === false && self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id'])) {
         $method = 'REQUEST';
         $notificationType = 'Modificação de Calendario';
         $part = 'othersAttendees';
         self::mountStruture($uri['id'], $schedulable, false, $data, $subject, $ical, $part, $method, $notificationType);
         $from = self::_getAttendeeOrganizer($schedulable);
         if (isset($part) && $part && count($part) > 0) {
             self::sendMail($data, $ical, implode(',', $part), $subject, $schedulableOld['type'] == '1' ? 'notify_modify_body' : 'notify_modify_body_task', $from);
         }
     }
 }
Beispiel #19
0
 /**
  * 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;
 }
Beispiel #20
0
 /**
  * Método que remove do ldap as informações do vacation
  *
  * @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     Cristiano Corrêa Schmidt
  * @param      <$uri>
  * @param      <$result>
  * @param      <$criteria>
  * @param      <$original>
  * @return     <void>
  * @access     public
  */
 public function deleteVacationRule(&$uri, &$params, &$criteria, $original)
 {
     if ($original['URI']['id'] === 'vacation') {
         $user = Controller::read(array('concept' => 'user', 'id' => config::me('uidNumber'), 'service' => 'OpenLDAP'));
         $ldapConf = Config::service('OpenLDAP', 'config');
         $con = ldap_connect($ldapConf['host']);
         ldap_set_option($con, LDAP_OPT_PROTOCOL_VERSION, 3);
         ldap_bind($con, $ldapConf['user'], $ldapConf['password']);
         $info = array();
         $info['vacationActive'] = 'FALSE';
         $info['vacationInfo'] = "";
         ldap_modify($con, $user['dn'], $info);
         ldap_close($con);
     }
 }
Beispiel #21
0
 private static function schedulable2calendarToObject($Schedulable, $user = false)
 {
     return Controller::service('PostgreSQL')->execResultSql('SELECT calendar_to_calendar_object.id as calendar_to_calendar_Object , calendar.name as calendar_name ,calendar.location as calendar_location, calendar.id as calendar_id FROM calendar_to_calendar_object , calendar , calendar_signature' . ' WHERE calendar_signature.user_uidnumber = ' . $user ? $user : Config::me('uidNumber') . ' AND calendar_signature.calendar_id = calendar.id' . ' AND calendar_to_calendar_object.calendar_id = calendar.id' . ' AND calendar_to_calendar_object.calendar_object_id = ' . addslashes($Schedulable));
 }
 public function create($URI, &$data)
 {
     switch ($URI['concept']) {
         case 'labeled':
             if (isset($data['folderName']) && isset($data['messageNumber']) && isset($data['labelId'])) {
                 $this->mbox = $this->open_mbox($data['folderName']);
                 imap_setflag_full($this->mbox, $data['messageNumber'], '$Label' . $data['labelId'], ST_UID);
                 return array('id' => $data['folderName'] . '/' . $data['messageNumber'] . '#' . $data['labelId']);
             }
             return array();
         case 'followupflagged':
             //deve ser gravado primeiro no imap, obtido o message-id e, depois gravado no banco
             if (isset($data['folderName']) && isset($data['messageNumber'])) {
                 $this->mbox = $this->open_mbox($data['folderName']);
                 $s = imap_setflag_full($this->mbox, $data['messageNumber'], '$Followupflagged', ST_UID);
                 $headers = imap_fetch_overview($this->mbox, $data['messageNumber'], FT_UID);
                 $data['messageId'] = $headers[0]->message_id;
                 /*
                  * TODO
                  * Verificar erro ao tentar setar uma flag com o limite de flags atingido
                  * onde o status retornado pelo imap_setflag_full é true mesmo não sendo possível
                  * a inserção da flag.
                  */
                 return $s && imap_last_error() != 'Too many user flags in mailbox' ? $data : array();
             } else {
                 if (isset($data['messageId'])) {
                     /**
                      * Busca pela mensagem com o messageId dado. Se uma pasta foi passada, busca nela,
                      * senão busca em todas.
                      */
                     $folders = array();
                     if (isset($data['folderName'])) {
                         $folders = array($data['folderName']);
                     } else {
                         $folder_list = $this->get_folders_list();
                         foreach ($folder_list as $folder) {
                             if (isset($folder['folder_id'])) {
                                 $folders[] = $folder['folder_id'];
                             }
                         }
                     }
                     foreach ($folders as $folder) {
                         $this->mbox = $this->open_mbox($folder);
                         if ($messages = imap_search($this->mbox, 'ALL TEXT "Message-Id: ' . $data['messageId'] . '"', SE_UID)) {
                             $s = imap_setflag_full($this->mbox, $messages[0], '$Followupflagged', ST_UID);
                             /**
                              * Stop searching in all folders
                              */
                             return $data;
                         }
                     }
                 }
             }
             return array();
         case 'message':
             require_once ROOTPATH . '/library/uuid/class.uuid.php';
             $GLOBALS['phpgw_info']['flags'] = array('noheader' => true, 'nonavbar' => true, 'currentapp' => 'expressoMail', 'enable_nextmatchs_class' => True);
             $return = array();
             require_once dirname(__FILE__) . '/../../services/class.servicelocator.php';
             $mailService = ServiceLocator::getService('mail');
             $msg_uid = $data['msg_id'];
             $body = $data['body'];
             $body = str_replace("&lt;", "&yzwkx;", $body);
             //Alterar as Entities padrão das tags < > para compatibilizar com o Expresso
             $body = str_replace("&gt;", "&xzwky;", $body);
             $body = str_replace("%nbsp;", "&nbsp;", $body);
             $body = html_entity_decode($body, ENT_QUOTES, 'ISO-8859-1');
             $body = str_replace("&yzwkx;", "&lt;", $body);
             $body = str_replace("&xzwky;", "&gt;", $body);
             $folder = mb_convert_encoding($data['folder'], "UTF7-IMAP", "ISO-8859-1, UTF-8");
             $folder = @preg_replace('/INBOX[\\/.]/i', "INBOX" . $this->imap_delimiter, $folder);
             /**
              * Gera e preenche o field Message-Id do header
              */
             $mailService->addHeaderField('Message-Id', UUID::generate(UUID::UUID_RANDOM, UUID::FMT_STRING) . '@Draft');
             $mailService->addHeaderField('Reply-To', mb_convert_encoding($data['input_reply_to'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
             $mailService->addHeaderField('Date', date("d-M-Y H:i:s"));
             $mailService->addTo(mb_convert_encoding($data['input_to'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
             $mailService->addCc(mb_convert_encoding($data['input_cc'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
             $mailService->addBcc(mb_convert_encoding($data['input_cco'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
             $mailService->setSubject(mb_convert_encoding($data['input_subject'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
             if (isset($data['input_important_message'])) {
                 $mailService->addHeaderField('Importance', 'High');
             }
             if (isset($data['input_return_receipt'])) {
                 $mailService->addHeaderField('Disposition-Notification-To', Config::me('mail'));
             }
             $this->rfc2397ToEmbeddedAttachment($mailService, $body);
             $isHTML = isset($data['type']) && $data['type'] == 'html' ? true : false;
             if (!$body) {
                 $body = ' ';
             }
             $mbox_stream = $this->open_mbox($folder);
             $attachment = json_decode($data['attachments'], TRUE);
             if (!empty($attachment)) {
                 foreach ($attachment as &$value) {
                     if ((int) $value > 0) {
                         $att = Controller::read(array('id' => $value, 'concept' => 'mailAttachment'));
                         if ($att['disposition'] == 'embedded' && $isHTML) {
                             $body = str_replace('"../prototype/getArchive.php?mailAttachment=' . $att['id'] . '"', '"' . mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1') . '"', $body);
                             $mailService->addStringImage(base64_decode($att['source']), $att['type'], mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
                         } else {
                             $mailService->addStringAttachment(base64_decode($att['source']), mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'), $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] : 'attachment');
                         }
                         unset($att);
                     } else {
                         $value = json_decode($value, true);
                         switch ($value['type']) {
                             case 'imapPart':
                                 $att = $this->getForwardingAttachment($value['folder'], $value['uid'], $value['part']);
                                 if (strstr($body, 'src="./inc/get_archive.php?msgFolder=' . $value['folder'] . '&msgNumber=' . $value['uid'] . '&indexPart=' . $value['part'] . '"') !== false) {
                                     $body = str_ireplace('src="./inc/get_archive.php?msgFolder=' . $value['folder'] . '&msgNumber=' . $value['uid'] . '&indexPart=' . $value['part'] . '"', 'src="' . $att['name'] . '"', $body);
                                     $mailService->addStringImage($att['source'], $att['type'], mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
                                 } else {
                                     $mailService->addStringAttachment($att['source'], mb_convert_encoding($att['name'], 'ISO-8859-1', 'UTF-8,ISO-8859-1'), $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] : 'attachment');
                                 }
                                 unset($att);
                                 break;
                             case 'imapMSG':
                                 $mbox_stream = $this->open_mbox($value['folder']);
                                 $rawmsg = $this->getRawHeader($value['uid']) . "\r\n\r\n" . $this->getRawBody($value['uid']);
                                 $mailService->addStringAttachment($rawmsg, mb_convert_encoding(base64_decode($value['name']), 'ISO-8859-1', 'UTF-8,ISO-8859-1'), 'message/rfc822', '7bit', 'attachment');
                                 unset($rawmsg);
                                 break;
                             default:
                                 break;
                         }
                     }
                 }
             }
             if ($isHTML) {
                 $mailService->setBodyHtml($body);
             } else {
                 $mailService->setBodyText(mb_convert_encoding($body, 'ISO-8859-1', 'UTF-8,ISO-8859-1'));
             }
             if (imap_append($mbox_stream, "{" . $this->imap_server . ":" . $this->imap_port . "}" . $folder, $mailService->getMessage(), "\\Seen \\Draft")) {
                 $status = imap_status($mbox_stream, "{" . $this->imap_server . ":" . $this->imap_port . "}" . $folder, SA_UIDNEXT);
                 $return['id'] = $status->uidnext - 1;
                 if ($data['uidsSave']) {
                     $this->delete_msgs(array('folder' => $folder, 'msgs_number' => $data['uidsSave']));
                 }
                 Logger::info('expressomail', 'SAVEMSG', 'ID: ' . $return['id'] . ' # ' . 'Subject:' . $data['input_subject']);
             }
             return $return;
     }
 }
 /**
  * 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;
 }
Beispiel #24
0
 function normalizeEvents($result, $timezones)
 {
     $mySig = Controller::find(array('concept' => 'calendarSignature'), array('calendar'), array('filter' => array('AND', array('=', 'type', '0'), array('=', 'user', Config::me('uidNumber')), array('=', 'isOwner', '0'))));
     $signedCalendars = array();
     if (is_array($mySig)) {
         foreach ($mySig as $v) {
             $tmp = Controller::find(array('concept' => 'calendarToPermission'), array('acl', 'owner'), array('filter' => array('AND', array('=', 'calendar', $v['calendar']), array('=', 'user', Config::me('uidNumber')))));
             $signedCalendars[$v['calendar']] = $tmp[0];
         }
     }
     $date = new DateTime('now', new DateTimeZone('UTC'));
     $DayLigth = array();
     foreach ($result as $i => $v) {
         $currentTimezone = isset($v['calendar']) && isset($timezones[$v['calendar']]) ? $timezones[$v['calendar']] : $v['timezone'];
         $date->setTimestamp((int) ($v['startTime'] / 1000));
         $date->setTimezone(new DateTimeZone($v['timezone']));
         $DayLigth['event']['startTime'] = $date->getTimestamp() + $date->getOffset() . '000';
         $date->setTimezone(new DateTimeZone($currentTimezone));
         $DayLigth['calendar']['startTime'] = $date->getTimestamp() + $date->getOffset() . '000';
         $date->setTimestamp((int) ($v['endTime'] / 1000));
         $date->setTimezone(new DateTimeZone($currentTimezone));
         $DayLigth['event']['endTime'] = $date->getTimestamp() + $date->getOffset() . '000';
         if (isset($v['due']) && $v['due'] != '0') {
             $date->setTimestamp((int) ($v['due'] / 1000));
             $DayLigth['event']['due'] = $date->getTimestamp() + $date->getOffset() . '000';
         } else {
             $DayLigth['event']['due'] = $v['due'];
         }
         $date->setTimezone(new DateTimeZone($currentTimezone));
         $DayLigth['calendar']['endTime'] = $date->getTimestamp() + $date->getOffset() . '000';
         $result[$i]['DayLigth'] = $DayLigth;
         if (isset($v['occurrences']) && count($v['occurrences']) > 0) {
             $date->setTimestamp((int) ($v['startTime'] / 1000));
             $date->setTimezone(new DateTimeZone($currentTimezone));
             foreach ($result[$i]['occurrences'] as &$o) {
                 $o = (int) ($o / 1000) + $date->getOffset() . '000';
             }
         }
         $attend = isset($signedCalendars[$result[$i]['calendar']]) ? Controller::read(array('concept' => 'participant'), null, array('filter' => array('AND', array('=', 'schedulable', $v['id']), array('=', 'user', $signedCalendars[$result[$i]['calendar']]['owner'])))) : Controller::read(array('concept' => 'participant'), null, array('filter' => array('AND', array('=', 'schedulable', $v['id']), array('=', 'user', Config::me('uidNumber')))));
         $result[$i]['unanswered'] = 0;
         if (count($attend) > 0 && !empty($attend)) {
             if (array_key_exists(0, $attend)) {
                 $attend = $attend[0];
             }
             if (isset($signedCalendars[$result[$i]['calendar']])) {
                 //Caso agenda compartilhada verificar tmb se tem compartilhamento de escrita
                 $result[$i]['editable'] = strpos($signedCalendars[$result[$i]['calendar']]['acl'], "w") >= 0 && (strstr($attend['acl'], "w") || strstr($attend['acl'], "o") || $attend['isOrganizer'] == '1') ? 1 : 0;
             } else {
                 $result[$i]['editable'] = strstr($attend['acl'], "w") || strstr($attend['acl'], "o") || $attend['isOrganizer'] == '1' ? 1 : 0;
             }
             if ($attend['status'] == STATUS_UNANSWERED && !isset($signedCalendars[$result[$i]['calendar']])) {
                 $result[$i]['unanswered'] = 1;
             }
         } else {
             $result[$i]['editable'] = $v['type'] == '2' ? 0 : 2;
         }
         if ($v['type'] == 2 && $v['tasks'] > 0) {
             $result[$i]['type'] = 3;
         }
     }
     return $this->toUtf8($result);
 }