コード例 #1
0
ファイル: response.php プロジェクト: dmitriz/Platform
function Streams_participating_response()
{
    if (!Q_Request::isAjax()) {
        return;
    }
    $max_limit = Q_Config::expect('Streams', 'db', 'limits', 'participating');
    $user = Users::loggedInUser(true);
    $type = Streams::requestedType();
    $limit = Streams::requestedField('limit', false, $max_limit);
    if ($limit > $max_limit) {
        throw new Q_Exception("limit is too large, must be <= {$max_limit}");
    }
    $offset = Streams::requestedField('offset', false, 0);
    $order = Streams::requestedField('order', false, true);
    $participating = array();
    $q = Streams_Participating::select('*')->where(array('userId' => $user->id));
    if ($type) {
        $q = $q->where(array('streamName' => new Db_Range($type . '/', true, false, true)));
    }
    if ($limit) {
        $q = $q->limit($limit, $offset);
    }
    if ($order) {
        $q = $q->orderBy('updatedTime', false);
    }
    $res_participating = $q->fetchDbRows();
    foreach ($res_participating as $part) {
        $part_safe = $part->exportArray();
        if (isset($part_safe)) {
            $participating[] = $part_safe;
        }
    }
    Q_Response::setSlot('participating', $participating);
    if (!Q_Request::slotName('streams')) {
        return;
    }
    $res_streams = array();
    $streamNames = array();
    foreach ($res_participating as $p) {
        $streamNames[$p->publisherId][] = $p->streamName;
    }
    foreach ($streamNames as $p_id => $names) {
        $res_streams[$p_id] = Streams::fetch($user->id, $p_id, $names);
    }
    $streams = array();
    $o = array('asUserId' => $user->id);
    foreach ($res_streams as $publisherId => $streams_array) {
        if (!empty($streams_array)) {
            $streams[$publisherId] = array();
            foreach ($streams_array as $streamName => $stream) {
                $streams[$publisherId][$streamName] = $stream->exportArray($o);
            }
        }
    }
    Q_Response::setSlot('streams', $streams);
}
コード例 #2
0
ファイル: content.php プロジェクト: AndreyTepaykin/Platform
function Trump_home_response_content($params)
{
    // Implement a home page for the user
    $user = Users::loggedInUser(true);
    $types = array('mobile' => 'mobileNumber', 'email' => 'emailAddress');
    $prompts = array('mobile' => 'Add a mobile number', 'email' => 'Add an email address');
    $identifiers = array();
    foreach ($types as $type => $field) {
        $prompt = $prompts[$type];
        $fieldPending = $field . 'Pending';
        $identifiers[$type] = $user->{$field} ? "<div class='Groups_identifier'>{$user->{$field}}</div>" : ($user->{$fieldPending} ? "<div><span class='Groups_moreinfo'>(pending)</span> {$user->{$fieldPending}}</div>" : "<div class='Groups_moreinfo'>{$prompt}</div>");
    }
    $roles = Users::roles(null, array('Websites/admins'));
    $isAdmin = !empty($roles['Websites/admins']);
    $app = Q_Config::expect('Q', 'app');
    $streamNames = Streams_Participating::select('streamName')->where(array('userId' => $user->id, 'publisherId' => $app, 'streamName' => new Db_Range('Places/', true, false, true)))->fetchAll(PDO::FETCH_COLUMN, 'streamName');
    $previewOptions = array('inplace' => array('inplace' => array('maxWidth' => '.Streams_preview_contents', 'editOnClick' => false)), 'icon' => false);
    return Q::view('Trump/content/home.php', compact('user', 'identifiers', 'isAdmin', 'streamNames', 'previewOptions'));
}
コード例 #3
0
 /**
  * Also removes counterpart row in Streams_Participating table
  * @method beforeSave
  * @param {array} $pk
  *	The primary key fields
  * @return {boolean}
  */
 function beforeRemove($pk)
 {
     $p = new Streams_Participating();
     $p->userId = $this->userId;
     $p->publisherId = $this->publisherId;
     $p->streamName = $this->streamName;
     $p->remove();
     return true;
 }