PHP Method User::findCurrent, codiad Code Examples

This page contains top rated real world PHP examples of method User::findCurrent from package codiad extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: update.php Project: studip/PluginMarket
0
 public function save_usage_action()
 {
     // delete old usage
     MarketPluginUsage::deleteBySQL('user_id = ? AND name = ?', array(User::findCurrent()->id, Request::get('tag')));
     // create new usages
     foreach (Request::getArray('plugins') as $pluginid) {
         MarketPluginUsage::create(array('plugin_id' => $pluginid, 'user_id' => User::findCurrent()->id, 'name' => Request::get('tag')));
         $this->done++;
     }
 }
Example #2
Show file File: online.php Project: ratbird/hope
0
 /**
  * Controller for all buddy related action.
  *
  * The following actions are supported:
  * - "add" to add a user to the current user's buddy list
  * - "remove" to remove a user from the current user's buddy list
  *
  * @param String $action The action to be executed
  */
 public function buddy_action($action = 'add')
 {
     $username = Request::username('username');
     if ($action === 'add' && $username !== null) {
         if (Contact::import(array('owner_id' => User::findCurrent()->id, 'user_id' => User::findByUsername($username)->id))->store()) {
             PageLayout::postMessage(MessageBox::success(_('Der Benutzer wurde zu Ihren Kontakten hinzugefügt.')));
         }
     } elseif ($action === 'remove' && $username !== null) {
         $contact = Contact::find(array(User::findCurrent()->id, User::findByUsername($username)->id));
         if ($contact && $contact->delete()) {
             PageLayout::postMessage(MessageBox::success(_('Der Benutzer gehört nicht mehr zu Ihren Kontakten.')));
         }
     }
     $this->redirect('online');
 }
Example #3
Show file File: presenting.php Project: studip/PluginMarket
0
 public function propose_usage_action($plugin_id)
 {
     $this->plugin = new MarketPlugin($plugin_id);
     // Submit propose usage
     if (Request::submitted('propose')) {
         CSRFProtection::verifyUnsafeRequest();
         MarketPluginUsage::create(array('plugin_id' => $plugin_id, 'user_id' => User::findCurrent()->id, 'name' => Request::get('used_at')));
         $this->redirect('presenting/details/' . $plugin_id);
     }
     $this->most_used = DBManager::get()->fetchFirst('SELECT name FROM pluginmarket_plugin_usages WHERE user_id = ? AND name NOT IN (SELECT name FROM pluginmarket_plugin_usages WHERE plugin_id = ?) GROUP BY name ORDER BY count(*)', array(User::findCurrent()->id, $plugin_id));
 }
Example #4
Show file File: MarketPluginUsage.php Project: studip/PluginMarket
0
 public function isEditable()
 {
     return $GLOBALS['perm']->have_perm('root') || $this->user_id == User::findCurrent() || $this->plugin->user_id == User::findCurrent()->id;
 }
Example #5
Show file File: _blubber.php Project: ratbird/hope
0
</div>
        </div>
    <? endif ?>
    <? if ($thread['context_type'] === "public") : ?>
        <? $sharingusers = $thread->getSharingUsers() ?>
        <? $sharing_user_ids = array_map(function ($v) { return $v['user_id']; }, $sharingusers) ?>
        <div class="reshares<?php 
echo count($sharingusers) > 0 ? " reshared" : "";
?>
">
            <? if (count($sharingusers)) : ?>
                <? if ((!User::findCurrent()->isFriendOf($thread) || $thread['external_contact']) && ($GLOBALS['user']->id !== $thread['user_id'])) : ?>
                    <? $sharingcontacts = "" ?>
                    <? $othersharing = 0 ?>
                    <? foreach ($sharingusers as $key => $user) {
                        if (User::findCurrent()->isFriendOf($user)) {
                            $url = $user->getURL();
                            $name = $user->getName();
                            if ($url) {
                                $sharingcontacts .= '<a href="'.$url.'" title="'.htmlReady($name).'">';
                            }
                            $sharingcontacts .= $user->getAvatar()->getImageTag(Avatar::SMALL, array('title' => $name));
                            if ($url) {
                                $sharingcontacts .= '</a>';
                            }
                        } else {
                            $othersharing++;
                        }
                    } ?>
                    <? if ($sharingcontacts) : ?>
                        <?php 
Example #6
Show file File: contact.php Project: ratbird/hope
0
 function vcard_action($group = null)
 {
     // Set constants for export
     $charset = 'utf-8';
     $filename = _('Kontakte');
     // Set layout
     $this->set_layout(null);
     // If we got an array of user
     if (Request::submitted('user')) {
         $user = User::findManyByUsername(Request::getArray('user'));
     }
     // If we got a group
     if ($group) {
         $user = User::findMany(Statusgruppen::find($group)->members->pluck('user_id'));
     }
     // Fallback to all contacts if we got nothing
     if (!$user) {
         $user = User::findCurrent()->contacts;
     }
     header("Content-type: text/x-vCard;charset=" . $charset);
     //application/octet-stream MIME
     header("Content-disposition: attachment; filename=" . $filename . ".vcf");
     header("Pragma: private");
     $this->vCard = vCard::export($user);
 }
Example #7
Show file File: Score.class.php Project: ratbird/hope
0
    /**
    * Retrieves the score for the current user
    *
    * @return       integer the score
    *
    */
    static function GetMyScore($user_or_id = null)
    {
        $user = $user_or_id ? User::toObject($user_or_id) : User::findCurrent();
        $cache = StudipCacheFactory::getCache();
        if ($cache->read("user_score_of_".$user->id)) {
            return $cache->read("user_score_of_".$user->id);
        }
        //Behold! The all new mighty score algorithm!
        //Step 1: Select all activities as mkdate-timestamps.
        //Step 2: Group these activities to timeslots of halfhours
        //        with COUNT(*) as a weigh of the timeslot.
        //Step 3: Calculate the measurement of the timeslot from the weigh of it.
        //        This makes the first activity count fully, the second
        //        almost half and so on. We use log_n to make huge amounts of
        //        activities to not count so much.
        //Step 4: Calculate a single score for each timeslot depending on the
        //        measurement and the mkdate-timestamp. Use arctan as the function
        //        here so that older activities tend to zero.
        //Step 5: Sum all scores from all timeslots together.
        $sql = "
            SELECT round(SUM((-atan(measurement / " . round(31556926 / self::MEASURING_STEP) . ") / PI() + 0.5) * 200)) as score
            FROM (
                SELECT ((unix_timestamp() / " . self::MEASURING_STEP . ") - timeslot) / (LN(weigh) + 1) AS measurement
                FROM (
                    SELECT (round(mkdate / " . self::MEASURING_STEP . ")) as timeslot, COUNT(*) AS weigh
                    FROM (
                        " . self::createTimestampQuery() . "
                    ) as mkdates
                    GROUP BY timeslot
                ) as measurements
            ) as dates
        ";
        $stmt = DBManager::get()->prepare($sql);
        $stmt->execute(array(':user' => $user->id));
        $score = $stmt->fetchColumn();
        if ($user->score && $user->score != $score) {
            $user->score = $score;
            $user->store();
        }
        $cache->write("user_score_of_".$user->id, $score, 60 * 5);

        return $score;
    }
Example #8
Show file File: studygroup.php Project: ratbird/hope
0
 /**
  * displays a paginated member overview of a studygroup
  *
  * @param string id of a studypgroup
  * @param string page number the current page
  *
  * @return void
  *
  */
 function members_action()
 {
     $id = $_SESSION['SessionSeminar'];
     PageLayout::setTitle(getHeaderLine($_SESSION['SessionSeminar']) . ' - ' . _("Teilnehmende"));
     Navigation::activateItem('/course/members');
     PageLayout::setHelpKeyword('Basis.StudiengruppenBenutzer');
     Request::set('choose_member_parameter', $this->flash['choose_member_parameter']);
     object_set_visit_module('participants');
     $this->last_visitdate = object_get_visit($id, 'participants');
     $sem = Course::find($id);
     $this->anzahl = StudygroupModel::countMembers($id);
     $this->groupname = $sem->getFullname();
     $this->sem_id = $id;
     $this->groupdescription = $sem->beschreibung;
     $this->moderators = $sem->getMembersWithStatus('dozent');
     $this->tutors = $sem->getMembersWithStatus('tutor');
     $this->autors = $sem->getMembersWithStatus('autor');
     $this->accepted = $sem->admission_applicants->findBy('status', 'accepted');
     $this->sem_class = Course::findCurrent()->getSemClass();
     $inviting_search = new SQLSearch("SELECT auth_user_md5.user_id, {$GLOBALS['_fullname_sql']['full_rev']} as fullname, username, perms " . "FROM auth_user_md5 " . "LEFT JOIN user_info ON (auth_user_md5.user_id = user_info.user_id) " . "LEFT JOIN seminar_user ON (auth_user_md5.user_id = seminar_user.user_id AND seminar_user.Seminar_id = '" . addslashes($id) . "') " . "WHERE perms  NOT IN ('root', 'admin') " . "AND " . get_vis_query() . " AND (username LIKE :input OR Vorname LIKE :input " . "OR CONCAT(Vorname,' ',Nachname) LIKE :input " . "OR CONCAT(Nachname,' ',Vorname) LIKE :input " . "OR Nachname LIKE :input OR {$GLOBALS['_fullname_sql']['full_rev']} LIKE :input) " . "ORDER BY fullname ASC", _("Nutzer suchen"), "user_id");
     $this->rechte = $GLOBALS['perm']->have_studip_perm("tutor", $id);
     $actions = new ActionsWidget();
     if ($this->rechte) {
         $mp = MultiPersonSearch::get('studygroup_invite_' . $id)->setLinkText(_('Neue Gruppenmitglieder-/innen einladen'))->setLinkIconPath("")->setTitle(_('Neue Gruppenmitglieder/-innen einladen'))->setExecuteURL($this->url_for('course/studygroup/execute_invite/' . $id, array('view' => Request::get('view'))))->setSearchObject($inviting_search)->addQuickfilter(_('Adressbuch'), User::findCurrent()->contacts->pluck('user_id'))->setNavigationItem('/course/members')->render();
         $element = LinkElement::fromHTML($mp, Icon::create('community+add', 'clickable'));
         $actions->addElement($element);
     }
     if ($this->rechte || $sem->getSemClass()['studygroup_mode']) {
         $actions->addLink(_('Nachricht an alle Gruppenmitglieder verschicken'), $this->url_for('course/studygroup/message/' . $id), Icon::create('mail', 'clickable'), array('data-dialog' => 1));
     }
     if ($actions->hasElements()) {
         Sidebar::get()->addWidget($actions);
     }
     $this->invitedMembers = StudygroupModel::getInvitations($id);
 }
Example #9
Show file File: score.php Project: ratbird/hope
0
 /**
  * Removes the user's score from the ranking list.
  */
 public function unpublish_action()
 {
     $user = User::findCurrent();
     $user->score = 0;
     $user->store();
     PageLayout::postMessage(MessageBox::success(_('Ihr Wert wurde von der Rangliste gelöscht.')));
     $this->redirect('score');
 }
Example #10
Show file File: streams.php Project: ratbird/hope
0
 /**
  * Current user is going to follow (add as buddy) the given user, who could
  * also be an external contact.
  */
 public function follow_user_action()
 {
     if (!$GLOBALS['perm']->have_perm("autor")) {
         throw new AccessDeniedException();
     }
     if (Request::get("external_contact")) {
         $user = BlubberExternalContact::find(Request::option("user_id"));
     } else {
         $user = new BlubberUser(Request::option("user_id"));
     }
     if (!$user->isNew()) {
         if (is_a($user, "BlubberExternalContact")) {
             $statement = DBManager::get()->prepare("INSERT IGNORE INTO blubber_follower " . "SET studip_user_id = :user_id, " . "external_contact_id = :contact_id, " . "left_follows_right = '1' " . "");
             $success = $statement->execute(array('user_id' => $GLOBALS['user']->id, 'contact_id' => $user->getId()));
             if ($success) {
                 NotificationCenter::postNotification('BlubberExternalContactDidAdd', $user);
             }
         } else {
             Contact::import(array('owner_id' => User::findCurrent()->id, 'user_id' => $user->id))->store();
         }
     }
     $this->render_json(array('success' => 1, 'message' => (string) MessageBox::success(_("Kontakt hinzugefügt"))));
 }
Example #11
Show file File: HelpTour.class.php Project: ratbird/hope
0
 /**
  * checks if tour is visible for current user
  */
 function isVisible()
 {
     if (!$this->settings->active) {
         return false;
     }
     $language = substr($GLOBALS['user']->preferred_language, 0, 2);
     if (!$language) {
         $language = 'de';
     }
     if ($language != $this->language) {
         return false;
     }
     $current_role = User::findCurrent() ? User::findCurrent()->perms : 'nobody';
     if (strpos($this->roles, $current_role) === false) {
         return false;
     }
     foreach ($this->audiences as $audience) {
         switch ($audience->type) {
             case 'inst':
                 $table_name = 'user_inst';
                 $field_name = 'Institut_id';
                 break;
             case 'sem':
                 $table_name = 'seminar_user';
                 $field_name = 'Seminar_id';
                 break;
             case 'studiengang':
                 $table_name = 'user_studiengang';
                 $field_name = 'studiengang_id';
                 break;
             case 'abschluss':
                 $table_name = 'user_studiengang';
                 $field_name = 'abschluss_id';
                 break;
             case 'userdomain':
                 $table_name = 'user_userdomains';
                 $field_name = 'userdomain_id';
                 break;
         }
         if ($audience->range_id and $table_name) {
             $query = 'SELECT * FROM ' . $table_name . ' WHERE user_id = ? AND ' . $field_name . ' = ?';
             $items = array($GLOBALS['user']->user_id, $audience->range_id);
             $statement = DBManager::get()->prepare($query);
             $statement->execute($items);
             $ret = $statement->fetchOne(PDO::FETCH_ASSOC);
             if (!count($ret)) {
                 return false;
             }
         } elseif ($table_name) {
             $query = 'SELECT * FROM ' . $table_name . ' WHERE user_id = ?';
             $items = array($GLOBALS['user']->user_id);
             $statement = DBManager::get()->prepare($query);
             $statement->execute($items);
             $ret = $statement->fetchOne(PDO::FETCH_ASSOC);
             if (count($ret)) {
                 return false;
             }
         }
     }
     return true;
 }
Example #12
Show file File: details.php Project: studip/PluginMarket
0
</h2>
<ul class="plugin-usages">
    <?php 
foreach ($marketplugin['uses'] as $use) {
    ?>
        <li>
            <a href="<?php 
    echo PluginEngine::getLink($plugin, array('search' => htmlReady($use->name)), "presenting/all");
    ?>
">
                <?php 
    echo htmlReady($use->name);
    ?>
            </a>
            <?php 
    if ($use->plugin->isWritable(User::findCurrent()->id)) {
        ?>
            (<?php 
        echo ObjectdisplayHelper::link($use->user);
        ?>
)
            <?php 
    }
    ?>
            <?php 
    if ($use->isEditable()) {
        ?>
                <a href="<?php 
        echo PluginEngine::getLink($plugin, array(), "presenting/delete_usage/" . $use->id);
        ?>
">
Example #13
Show file File: my_realm.php Project: ratbird/hope
0
 public static function getStudygroups()
 {
     $courses = array();
     $modules = new Modules();
     $studygroups = User::findCurrent()->course_memberships->filter(function ($c) {
         return $c->course->getSemClass()->offsetGet('studygroup_mode');
     })->toGroupedArray('seminar_id');
     $param_array = 'name seminar_id visible veranstaltungsnummer start_time duration_time status visible ';
     $param_array .= 'chdate admission_binding modules admission_prelim';
     $courses = Course::findAndMapMany(function ($course) use($param_array, $studygroups, $modules) {
         $ret = $course->toArray($param_array);
         $ret['sem_class'] = $course->getSemClass();
         $ret['start_semester'] = $course->start_semester->name;
         $ret['end_semester'] = $course->end_semester->name;
         $ret['obj_type'] = 'sem';
         $ret['last_visitdate'] = object_get_visit($course->id, 'sem', 'last');
         $ret['visitdate'] = object_get_visit($course->id, 'sem', '');
         $ret['user_status'] = $studygroups[$course->id]['status'];
         $ret['gruppe'] = $studygroups[$course->id]['gruppe'];
         $ret['modules'] = $modules->getLocalModules($course->id, 'sem', $course->modules, $course->status);
         MyRealmModel::getObjectValues($ret);
         return $ret;
     }, array_keys($studygroups));
     return $courses;
 }
Example #14
Show file File: profile.php Project: ratbird/hope
0
 /**
  * Adds the user identified by the variable username to the current user's
  * contacts.
  */
 public function add_buddy_action()
 {
     $username = Request::username('username');
     $user = User::findByUsername($username);
     $current = User::findCurrent();
     $current->contacts[] = $user;
     $current->store();
     PageLayout::postMessage(MessageBox::success(_('Der Nutzer wurde zu Ihren Kontakten hinzugefügt.')));
     $this->redirect('profile/index?username=' . $username);
 }