Exemple #1
0
 function postContent()
 {
     $body = strip_tags($this->getInput('body'));
     $name = strip_tags($this->getInput('name'));
     $url = trim($this->getInput('url'));
     $url2 = trim($this->getInput('url-2'));
     $validator = $this->getInput('validator');
     if (!empty($url2)) {
         $this->deniedContent();
     }
     $this->referrerGatekeeper();
     if (!empty($body) && !empty($name) && !empty($validator)) {
         if ($object = Entity::getByUUID($validator)) {
             if ($url = Webservice::sanitizeURL($url)) {
                 if ($content = Webservice::get($url)) {
                     if ($content['response'] == '200') {
                         $icon = Webmention::getIconFromWebsiteContent($content['content'], $url);
                     }
                 }
             }
             if (empty($icon)) {
                 $bn = hexdec(substr(md5($url), 0, 15));
                 $number = 1 + $bn % 5;
                 $icon = \Idno\Core\site()->config()->url . 'gfx/users/default-' . str_pad($number, 2, '0', STR_PAD_LEFT) . '.png';
             }
             $object->addAnnotation('reply', $name, $url, $icon, $body);
             $this->forward($object->getDisplayURL());
         }
     }
 }
Exemple #2
0
 function postContent()
 {
     $this->createGatekeeper();
     // User is logged in and can post content
     // Get variables
     $body = $this->getInput('body');
     $object_uuid = $this->getInput('object');
     $type = $this->getInput('type');
     $user = \Idno\Core\site()->session()->currentUser();
     if ($type != 'like') {
         $type = 'reply';
     }
     if ($object = Entity::getByUUID($object_uuid)) {
         $has_liked = false;
         if ($type == 'like') {
             if ($like_annotations = $object->getAnnotations('like')) {
                 foreach ($like_annotations as $like) {
                     if ($like['owner_url'] == \Idno\Core\site()->session()->currentUser()->getURL()) {
                         $object->removeAnnotation($like['permalink']);
                         $object->save();
                         $has_liked = true;
                     }
                 }
             }
         }
         if (!$has_liked) {
             if ($object->addAnnotation($type, $user->getTitle(), $user->getURL(), $user->getIcon(), $body)) {
                 $object->save();
             }
         }
         $this->forward($object->getURL() . '#comments');
     }
 }
 /**
  * Get the actor associated with this entity
  */
 function getActor()
 {
     return \Idno\Common\Entity::getByUUID($this->actor);
 }
 /**
  * Get the target object associated with this entry
  * @return \Idno\Common\Entity
  */
 function getTarget()
 {
     return \Idno\Common\Entity::getByUUID($this->target);
 }
Exemple #5
0
 /**
  * Retrieve the indirect object of the action
  * @return bool|Entity
  */
 function getTarget()
 {
     if (is_string($this->target)) {
         return Entity::getByUUID($this->target);
     }
     return $this->target;
 }