Beispiel #1
0
 public function sendTweet($msg)
 {
     $input = array('msg' => $msg);
     $v = new InputValidator($input);
     $v->string()->validate('msg', 'Mensagem');
     $v->throwException();
     $consumer_key = $this->_sm_credentials->row['tw_consumer_key'];
     $consumer_secret = $this->_sm_credentials->row['tw_consumer_secret'];
     $access_token = $this->_sm_credentials->row['tw_access_token'];
     $access_secret = $this->_sm_credentials->row['tw_access_secret'];
     //_# ENVIA O TWEET
     try {
         $twitter = new Twitter($consumer_key, $consumer_secret, $access_token, $access_secret);
         $twitter->send($msg);
     } catch (Exception $e) {
         if ($e->getMessage() == 'Status is a duplicate.') {
             throw new Exception('Essa mensagem já foi publicada anteriormente.');
         } else {
             throw new Exception('Erro ao enviar tweet: ' . $e->getMessage());
         }
     }
     $f = new TableFilter($this->_table, $input);
     $f->newId()->filter('id_tweet');
     $f->timestamp()->filter('date');
     $f->string()->filter('msg');
     //
     $this->_dao->insert($this->_table);
     //_# AVISA O MODEL
     $this->_model->sentTweet($this->_table->id_tweet);
 }
Beispiel #2
0
 public function update($input)
 {
     //
     $f = new TableFilter($this->_table, $input);
     $f->string()->filter('sequence');
     $f->string()->filter('label');
     $f->string()->filter('credit');
     //
     $this->_dao->update($this->_table, array($this->_id_photo_item . ' = ?' => $this->getId()));
 }
Beispiel #3
0
 public function toggleActive($id, $active)
 {
     $table = new Table($this->_model->getTableName());
     $f = new TableFilter($table, array('is_active' => $active));
     $f->intval()->filter('is_active');
     $title = $this->_model->_entity->getTitle();
     $tableHistory = $this->_model->getById($id);
     $this->_dao->update($table, array($this->_model->getIdName() . ' = ?' => $id));
     $this->_model->log('U', $tableHistory[$title], $table, $tableHistory);
 }
 public function update_password($input)
 {
     $v = new InputValidator($input);
     $v->stringEqual('password2')->validate('password', 'Senha');
     //
     $this->validateToken($input['token'], $v);
     //
     $v->throwException();
     //
     $f = new TableFilter($this->_table, $input);
     $f->crypted()->filter('password');
     $f->null()->filter('password_change_date');
     //
     $this->_dao->update($this->_table, array('id_admin = ?' => $input['token']));
 }
Beispiel #5
0
 public function update($input)
 {
     $v = new InputValidator($input);
     $v->string()->validate('name', 'Nome');
     $v->stringEmail()->validate('email', 'E-mail');
     $has_avatar = $v->upload()->validate('avatar', 'Avatar');
     $v->throwException();
     //
     $f = new TableFilter($this->_table, $input);
     $f->string()->filter('name');
     $f->string()->filter('email');
     $f->crypted()->filter('password');
     //
     $mf = new MoveFiles();
     $f->uploaded("/system/uploads/admin/{$this->getId()}/avatar", $has_avatar, $mf)->filter('avatar');
     //
     $mf->move();
     //
     $this->dao_update();
     $this->relogin();
 }
Beispiel #6
0
 /**
  *
  * @param type $input array(
  * 'url' => '',
  * ' name' => '',
  * 'title' => '',
  * 'parent_table' => '',
  * 'parent_id_field' => '',
  * 'parent_id_value' => '',
  * 'id_issuu' => '',
  * 'delete_previous' => ''
  * )
  */
 public function insertComplete($input)
 {
     if ($input['delete_previous']) {
         $this->deleteComplete($input);
     }
     // insere na api
     $response = $this->_api->document_url_upload($input['url'], $input['name'], $input['title']);
     // gera embed
     $embed = $this->_api->document_embed_add($response['document_id'], 500, 500);
     // insere na tabela issuu
     $f = new TableFilter($this->_table, array('document_id' => $response['document_id'], 'name' => $response['name'], 'link' => $response['link'], 'embed_id' => $embed['id'], 'data_config_id' => $embed['dataConfigId']));
     $f->newId()->filter('id_issuu');
     $f->string()->filter('name');
     $f->string()->filter('link');
     $f->string()->filter('document_id');
     $f->string()->filter('embed_id');
     $f->string()->filter('data_config_id');
     $this->_dao->insert($this->_table);
     // atualiza tabela parent com o id da tabela issuu
     $parent_table = new Table($input['parent_table']);
     $parent_table->id_issuu = $this->getId();
     $this->_dao->update($parent_table, array("{$input['parent_id_field']} = ?" => $input['parent_id_value']));
 }
 public function insertFromLink($link)
 {
     $response_text = file_get_contents("http://api.soundcloud.com/resolve.json?url={$link}&client_id={$this->_sm_credentials->row['sc_client_id']}");
     $response_json = json_decode($response_text);
     if (json_last_error()) {
         throw new Exception('Não foi possível converter pra JSON: ' . $response_text);
     }
     $track_id = $response_json->id;
     $permalink_url = $response_json->permalink_url;
     $f = new TableFilter($this->_table, array('track_id' => $track_id, 'track_permalink' => $permalink_url));
     $f->newId()->filter('id_soundcloud');
     $f->string()->filter('track_id');
     $f->string()->filter('track_permalink');
     $this->_dao->insert($this->_table);
     return $this->_table->id_soundcloud;
 }
 public function update($input)
 {
     $f = new TableFilter($this->_table, $input);
     $f->string()->filter('fb_app_id');
     $f->string()->filter('fb_app_secret');
     $f->string()->filter('fb_page');
     $f->string()->filter('fb_access_token');
     $f->string()->filter('tw_user');
     $f->string()->filter('tw_consumer_key');
     $f->string()->filter('tw_consumer_secret');
     $f->string()->filter('tw_access_token');
     $f->string()->filter('tw_access_secret');
     $f->string()->filter('issuu_key');
     $f->string()->filter('issuu_secret');
     $f->string()->filter('sc_client_id');
     $f->string()->filter('sc_client_secret');
     $f->string()->filter('sc_token');
     $f->string()->filter('youtube_user');
     $f->string()->filter('youtube_id');
     $f->string()->filter('youtube_secret');
     $f->string()->filter('youtube_token');
     $f->string()->filter('googleplus_user');
     $f->string()->filter('instagram_user');
     $f->string()->filter('link_twitter');
     $f->string()->filter('link_facebook');
     $f->string()->filter('link_google');
     $f->string()->filter('link_instagram');
     $f->string()->filter('link_flickr');
     $f->string()->filter('link_youtube');
     $f->string()->filter('link_issuu');
     $f->string()->filter('link_soundcloud');
     if (isset($input['link_cs'])) {
         $f->string()->filter('link_cs');
     }
     $f->string()->filter('discus_username');
     if (isset($input['ga_view'])) {
         $f->string()->filter('ga_view');
     }
     $this->dao_update(false);
 }
Beispiel #9
0
 protected function updateSequence($sequence, $id)
 {
     $entity_id = $this->_entity->getId();
     $entity_tbl = $this->_entity->getTbl();
     $table = new Table($entity_tbl);
     $f = new TableFilter($table, array('sequence' => $sequence));
     $f->intval()->filter('sequence');
     $this->_dao->update($table, array($entity_id . ' = ? ' => $id));
 }
Beispiel #10
0
 public function post($input)
 {
     try {
         $v = new InputValidator($input);
         $v->string()->validate('name', 'Nome');
         $v->string()->validate('link', 'Link');
         $v->throwException();
         //
         $fileSystem = new FileSystem('tokens');
         $facebookKey = new SocialKeys();
         $facebookKey->setClientId(FACEBOOK_CLIENT_ID);
         $facebookKey->setClientSecret(FACEBOOK_CLIENT_SECRET);
         $facebookKey->setRedirectUri(FACEBOOK_REDIRECT_URL);
         $facebookAuth = new FacebookAuth($facebookKey, $fileSystem);
         $fb = new \Facebook\Facebook(['app_id' => FACEBOOK_CLIENT_ID, 'app_secret' => FACEBOOK_CLIENT_SECRET, 'default_graph_version' => 'v2.7', 'default_access_token' => $facebookAuth->getToken()['access_token']]);
         $facebookPost = new \dinsocial\Facebook\PageFeed($fb);
         $id_post = $facebookPost->postPageFeed(FACEBOOK_PAGE_ID, $input['link'], $input['name'], $input['picture'], $input['description'], $input['message']);
         if ($id_post) {
             $f = new TableFilter($this->_table, $input);
             $f->newId()->filter('id_facepost');
             $f->timestamp()->filter('date');
             $f->string()->filter('name');
             $f->string()->filter('link');
             $f->string()->filter('picture');
             $f->string()->filter('description');
             $f->string()->filter('message');
             //
             $this->_dao->insert($this->_table);
             //_# AVISA O MODEL
             $this->_model->sentPost($this->_table->id_facepost);
         }
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
Beispiel #11
0
 public function beforeUpdate($tableHistory)
 {
     $entity_sequence = $this->_entity->getSequence();
     if (count($entity_sequence) && isset($entity_sequence['dependence'])) {
         $dependence_field_itens = $entity_sequence['dependence'];
         if (!is_array($dependence_field_itens)) {
             $dependence_field_itens = array(0 => $dependence_field_itens);
         }
         foreach ($dependence_field_itens as $dependence_field) {
             $dependence_value = $this->_table->{$dependence_field};
             if ($tableHistory[$dependence_field] != $dependence_value) {
                 $seq = new SequenceModel();
                 $seq->changeSequence(array('tbl' => $this->getTableName(), 'id' => $this->getId(), 'sequence' => 0));
                 $f = new TableFilter($this->_table, array());
                 $f->sequence($this->_dao, $this->_entity)->filter('sequence');
             }
         }
     }
 }
Beispiel #12
0
 public function delete($itens)
 {
     foreach ($itens as $item) {
         $entity = $this->_entities->getEntity($item['name']);
         $entity_id = $entity->getId();
         $entity_title = $entity->getTitle();
         $entity_tbl = $entity->getTbl();
         $entity_sequence = $entity->getSequence();
         $model = $entity->getModel();
         //_# Se ele não possui lixeira, ignora
         if (!$entity->hasTrash()) {
             //ignore
         } else {
             if (count($entity_sequence)) {
                 $seq = new SequenceModel();
                 $seq->changeSequence(array('tbl' => $entity_tbl, 'id' => $item['id'], 'sequence' => 0));
             }
             $tableHistory = $model->getById($item['id']);
             $this->deleteChildrens($entity, $item['id'], $tableHistory);
             $table = new Table($entity_tbl);
             $f = new TableFilter($table, array('is_del' => '1'));
             $f->timestamp()->filter('del_date');
             $f->intval()->filter('is_del');
             $this->_dao->update($table, array($entity_id . ' = ?' => $item['id']));
             $this->log('T', $tableHistory[$entity_title], $table, $tableHistory);
         }
     }
 }