예제 #1
0
파일: vCard.php 프로젝트: ratbird/hope
 /**
  * Export of a single user
  * 
  * @param User $user Userobject
  * @return String vCard export string
  */
 private static function exportUser(User $user)
 {
     // If user is not visible export nothing
     if (!get_visibility_by_id($user->id)) {
         return "";
     }
     // vCard exportheader
     $vCard['BEGIN'] = 'VCARD';
     $vCard['VERSION'] = '3.0';
     $vCard['PRODID'] = 'Stud.IP//' . $GLOBALS['UNI_NAME_CLEAN'] . '//DE';
     $vCard['REV'] = date('Y-m-d  H:i:s');
     $vCard['TZ'] = date('O');
     // User specific data
     //Fullname
     $vCard['FN'] = studip_utf8encode($user->getFullname());
     //Name
     $vCard['N'][] = studip_utf8encode($user->Nachname);
     $vCard['N'][] = studip_utf8encode($user->Vorname);
     $vCard['N'][] = studip_utf8encode($user->info->title_rear);
     $vCard['N'][] = studip_utf8encode($user->info->title_front);
     // Adress
     if (Visibility::verify('privadr', $user->id)) {
         $vCard['ADR;TYPE=HOME'] = studip_utf8encode($user->info->privadr);
     }
     // Tel
     if (Visibility::verify('private_phone', $user->id)) {
         $vCard['TEL;TYPE=HOME'] = studip_utf8encode($user->info->privatnr);
     }
     if (Visibility::verify('private_cell', $user->id)) {
         $vCard['TEL;TYPE=CELL'] = studip_utf8encode($user->info->privatcell);
     }
     // Email
     if (get_local_visibility_by_id($user->id, 'email')) {
         $vCard['EMAIL'] = studip_utf8encode($user->email);
     }
     // Photo
     if (Visibility::verify('picture', $user->id)) {
         // Fetch avatar
         $avatar = Avatar::getAvatar($user->id);
         // Only export if
         if ($avatar->is_customized()) {
             $vCard['PHOTO;JPEG;ENCODING=BASE64'] = base64_encode(file_get_contents($avatar->getFilename(Avatar::NORMAL)));
         }
     }
     // vCard end
     $vCard['END'] = 'VCARD';
     // Produce string
     foreach ($vCard as $index => $value) {
         $exportString .= $value ? $index . ':' . (is_array($value) ? join(';', $value) : $value) . "\r\n" : "";
     }
     return $exportString;
 }
예제 #2
0
파일: User.php 프로젝트: ratbird/hope
 /**
  * getUser - retrieves data of a user
  *
  * @get /user/:user_id
  * @get /user
  */
 public function getUser($user_id = '')
 {
     $user_id = $user_id ?: $GLOBALS['user']->id;
     $user = \User::find($user_id);
     if (!$user) {
         $this->halt(404, sprintf('User %s not found', $user_id));
     }
     $visibilities = get_local_visibility_by_id($user_id, 'homepage');
     if (is_array(json_decode($visibilities, true))) {
         $visibilities = json_decode($visibilities, true);
     } else {
         $visibilities = array();
     }
     $get_field = function ($field, $visibility) use($user_id, $user, $visibilities) {
         if (!$user[$field] || !is_element_visible_for_user($GLOBALS['user']->id, $user_id, $visibilities[$visibility])) {
             return '';
         }
         return $user[$field];
     };
     $avatar = \Avatar::getAvatar($user_id);
     $user = array('user_id' => $user_id, 'username' => $user['username'], 'name' => self::getNamesOfUser($user), 'perms' => $user['perms'], 'email' => get_visible_email($user_id), 'avatar_small' => $avatar->getURL(\Avatar::SMALL), 'avatar_medium' => $avatar->getURL(\Avatar::MEDIUM), 'avatar_normal' => $avatar->getURL(\Avatar::NORMAL), 'avatar_original' => $avatar->getURL(\Avatar::ORIGINAL), 'phone' => $get_field('privatnr', 'private_phone'), 'homepage' => $get_field('Home', 'homepage'), 'privadr' => strip_tags($get_field('privadr', 'privadr')));
     $query = "SELECT value\n                  FROM user_config\n                  WHERE field = ? AND user_id = ?";
     $statement = \DBManager::get()->prepare($query);
     $statement->execute(array('SKYPE_NAME', $user_id));
     $user['skype'] = $statement->fetchColumn() ?: '';
     $statement->closeCursor();
     if ($user['skype']) {
         $statement->execute(array('SKYPE_ONLINE_STATUS', $user_id));
         $user['skype_show'] = (bool) $statement->fetchColumn();
     } else {
         $user['skype_show'] = false;
     }
     // Data fields
     $datafields = array();
     foreach (\DataFieldEntry::getDataFieldEntries($user_id, 'user') as $entry) {
         if (!$entry->isVisible()) {
             continue;
         }
         if (!\Visibility::verify($entry->getID(), $user_id)) {
             continue;
         }
         $datafields[] = array('type' => $entry->getType(), 'id' => $entry->getId(), 'name' => $entry->getName(), 'value' => $entry->getValue());
     }
     $user['datafields'] = $datafields;
     $this->etag(md5(serialize($user)));
     return $user;
 }
예제 #3
0
 /**
  * Collect user datafield informations
  *
  * @return array
  */
 function getDatafields()
 {
     // generische Datenfelder aufsammeln
     $short_datafields = array();
     $long_datafields = array();
     foreach (DataFieldEntry::getDataFieldEntries($this->current_user->user_id, 'user') as $entry) {
         if ($entry->isVisible() && $entry->getDisplayValue() && Visibility::verify($entry->getID(), $this->current_user->user_id)) {
             if ($entry instanceof DataFieldTextareaEntry) {
                 $long_datafields[] = $entry;
             } else {
                 $short_datafields[] = $entry;
             }
         }
     }
     return array('long' => $long_datafields, 'short' => $short_datafields);
 }
 private function getContentOwnCategories () {
     $stm = DBManager::get()->prepare(
         "SELECT kategorie_id, name, content "
         . "FROM kategorien "
         . "WHERE range_id = ? "
         . "ORDER BY priority");
     $stm->execute(array($this->user_id));
     $i = 0;
     while ($row = $stm->fetch(PDO::FETCH_ASSOC)) {
         if (Visibility::verify('kat_'.$row['kategorie_id'], $this->user_id)) {
             $content['OWNCATEGORIES']['OWNCATEGORY'][$i]['OWNCATEGORY_TITLE'] = ExternModule::ExtHtmlReady($row['name']);
             $content['OWNCATEGORIES']['OWNCATEGORY'][$i]['OWNCATEGORY_CONTENT'] = ExternModule::ExtFormatReady($row['content']);
             $content['OWNCATEGORIES']['OWNCATEGORY'][$i]['OWNCATEGORY_NO'] = $i + 1;
             $i++;
         }
     }
     return $content;
 }
예제 #5
0
파일: streams.php 프로젝트: ratbird/hope
 /**
  * Writes a comment on a thread and outputs the metadata of new comment as json.
  * @throws AccessDeniedException
  */
 public function comment_action()
 {
     if (!Request::isPost()) {
         throw new Exception("GET not supported");
     }
     $context = Request::option("context");
     $thread = new BlubberPosting(Request::option("thread"));
     if ($thread['context_type'] === "course" && $GLOBALS['SessSemName']['class'] === "sem") {
         $seminar = new Seminar($context);
         if ($seminar->write_level > 0 && !$GLOBALS['perm']->have_studip_perm("autor", $context)) {
             throw new AccessDeniedException();
         }
     }
     BlubberPosting::$course_hashes = $thread['context_type'] === "course" ? $thread['Seminar_id'] : false;
     if (!$thread->isNew() && $thread['Seminar_id'] === $context) {
         $output = array();
         $posting = new BlubberPosting();
         $posting['context_type'] = $thread['context_type'];
         $posting['seminar_id'] = $thread['Seminar_id'];
         $posting['root_id'] = $posting['parent_id'] = $thread->getId();
         $posting['name'] = "Re: " . $thread['name'];
         if ($GLOBALS['user']->id !== "nobody") {
             $posting['user_id'] = $GLOBALS['user']->id;
         } else {
             if (Request::get("anonymous_security") === $_SESSION['blubber_anonymous_security']) {
                 $contact_user = BlubberExternalContact::findByEmail(Request::get("anonymous_email"));
                 $_SESSION['anonymous_email'] = Request::get("anonymous_email");
                 $_SESSION['anonymous_name'] = $contact_user['name'] = Request::get("anonymous_name");
                 $contact_user->store();
                 $posting['user_id'] = $contact_user->getId();
                 $posting['external_contact'] = 1;
             } else {
                 throw new AccessDeniedException("No permission to write posting.");
             }
         }
         $posting['author_host'] = $_SERVER['REMOTE_ADDR'];
         $posting['description'] = studip_utf8decode(Request::get("content"));
         $posting->store();
         BlubberPosting::$mention_posting_id = $posting->getId();
         StudipTransformFormat::addStudipMarkup("mention1", '@\\"[^\\n\\"]*\\"', null, "BlubberPosting::mention");
         StudipTransformFormat::addStudipMarkup("mention2", '@[^\\s]*[\\d\\w_]+', null, "BlubberPosting::mention");
         $content = transformBeforeSave(studip_utf8decode(Request::get("content")));
         $posting['description'] = $content;
         $posting->store();
         $factory = new Flexi_TemplateFactory($this->plugin->getPluginPath() . "/views/streams");
         $template = $factory->open("comment.php");
         $template->set_attribute('posting', $posting);
         $template->set_attribute('course_id', $thread['Seminar_id']);
         $output['content'] = $template->render($template->render());
         $output['mkdate'] = time();
         $output['posting_id'] = $posting->getId();
         //Notifications:
         $user_ids = array();
         if ($thread['user_id'] && $thread['user_id'] !== $GLOBALS['user']->id) {
             $user_ids[] = $thread['user_id'];
         }
         foreach ((array) $thread->getChildren() as $comment) {
             if ($comment['user_id'] && $comment['user_id'] !== $GLOBALS['user']->id && !$comment['external_contact']) {
                 $user_ids[] = $comment['user_id'];
             }
         }
         $user_ids = array_unique($user_ids);
         foreach ($user_ids as $user_id) {
             setTempLanguage($user_id);
             $avatar = Visibility::verify('picture', $GLOBALS['user']->id, $user_id) ? Avatar::getAvatar($GLOBALS['user']->id) : Avatar::getNobody();
             PersonalNotifications::add($user_id, PluginEngine::getURL($this->plugin, array('cid' => $thread['context_type'] === "course" ? $thread['Seminar_id'] : null), "streams/thread/" . $thread->getId()), sprintf(_("%s hat einen Kommentar geschrieben"), get_fullname()), "posting_" . $posting->getId(), $avatar->getURL(Avatar::MEDIUM));
             restoreLanguage();
         }
         $this->render_json($output);
     } else {
         $this->render_json(array('error' => "Konnte thread nicht zuordnen."));
     }
 }
예제 #6
0
function kontakt ($module, $row, $separate = FALSE) {
    $attr_table = $module->config->getAttributes("Contact", "table");
    $attr_tr = $module->config->getAttributes("Contact", "table");
    $attr_td = $module->config->getAttributes("Contact", "td");
    $attr_fonttitle = $module->config->getAttributes("Contact", "fonttitle");
    $attr_fontcontent = $module->config->getAttributes("Contact", "fontcontent");

    $out = "<table$attr_table>\n";
    if (!$separate) {
        $out .= "<tr$attr_tr>";
        $out .= "<td colspan=\"2\"$attr_td>";
        $out .= "<font$attr_fonttitle>";
        if ($headline = $module->config->getValue("Contact", "headline"))
            $out .= "$headline</font>\n";
        else
            $out .= "</font>\n";

        $out .= "<font$attr_fontcontent>";

        if (!$module->config->getValue("Contact", "hidepersname"))
            $out .= "<br><br>" . htmlReady($row['fullname'], TRUE) . "\n";
        if ($module->config->getValue('Contact', 'showinstgroup')) {
            $allgroups = GetAllStatusgruppen($module->config->range_id, $row['user_id']);
            array_walk($allgroups, function(&$v, $k, $user_id) {
                $s = Statusgruppen::find($k);
                $v['role']->name = htmlReady($s->getGenderedName($user_id));
            }, $row['user_id']);
            if ($gruppen = GetRoleNames($allgroups))
                $out .= "<br>" . htmlReady(join(", ", array_values($gruppen)));
        }
        // display name of institution (as link)
        if ($row['Name']) {
            $br_out = "";
            if ($module->config->getValue("Contact", "hideinstname") != '1') {
                if ($module->config->getValue("Contact", "hideinstname") == 'link' && $row['url']) {
                    $url = htmlReady(trim($row['url']));
                    if (!stristr($url, "http://"))
                        $url = "http://$url";
                    $out .= "<br><br><a href=\"$url\" target=\"_blank\">";
                    $out .= htmlReady($row['Name'], TRUE) . "</a><br>";
                }
                else
                    $out .= "<br><br>" . htmlReady($row['Name'], TRUE) . "<br>";
            }
            if ($module->config->getValue("Contact", "adradd"))
                $out .= "<br>" . $module->config->getValue("Contact", "adradd");
        }

        $out .= "<br>";
        if ($row['Strasse']) {
            $out .= "<br>" . htmlReady($row['Strasse'], TRUE);
            if($row['Plz'])
            $out .= "<br>" . htmlReady($row['Plz'], TRUE);
        }
      $out .= "<br><br></font></td></tr>\n";
    }
    $order = $module->config->getValue("Contact", "order");
    $visible = $module->config->getValue("Contact", "visible");
    $alias_contact = $module->config->getValue("Contact", "aliases");
    foreach ($order as $position) {
        $data_field = $module->data_fields["contact"][$position];
        if (!$visible[$position] || !$row[$data_field])
            continue;
        switch ($data_field) {
            case 'Email' :
                if ($separate || !$module->config->getValue('Contact', 'separatelinks')) {
                    $email_address = get_visible_email($row['user_id']);
                    $out .= "<tr$attr_tr>";
                    $out .= "<td$attr_td>";
                    $out .= "<font$attr_fonttitle>";
                    $out .= $alias_contact[$position] . "</font></td>";
                    $out .= "<td$attr_td>";
                    $out .= "<font$attr_fontcontent>";
                    $mail = trim(htmlReady($email_address));
                    $out .= "<a href=\"mailto:$mail\">$mail</a>";
                }
                break;
            case 'Home' :
                if (($separate || !$module->config->getValue('Contact', 'separatelinks')) &&
                       true�|| Visibility::verify('homepage', $row['user_id'])) {
                    $out .= "<tr$attr_tr>";
                    $out .= "<td$attr_td>";
                    $out .= "<font$attr_fonttitle>";
                    $out .= $alias_contact[$position] . "</font></td>";
                    $out .= "<td$attr_td>";
                    $out .= "<font$attr_fontcontent>";
                    $out .= formatLinks($row['Home']);
                }
                break;
            default:
                if (!$separate) {
                    $out .= "<tr$attr_tr>";
                    $out .= "<td$attr_td>";
                    $out .= "<font$attr_fonttitle>";
                    $out .= $alias_contact[$position] . "</font></td>";
                    $out .= "<td$attr_td>";
                    $out .= "<font$attr_fontcontent>";
                    $out .= htmlReady($row[$data_field], TRUE);
                }
        }
        if ($row[$data_field])
            $out .= "</font></td></tr>\n";
    }
    $out .= "</table>\n";

    return $out;
}
예제 #7
0
 /**
  * Return if avatar is visible to the current user.
  * Also set the user_id of avatar to nobody if not visible to current user.
  * @return boolean: true if visible
  */
 protected function checkAvatarVisibility()
 {
     $visible = Visibility::verify('picture', $this->user_id);
     if (!$visible) {
         $this->user_id = 'nobody';
     }
     return $visible;
 }