예제 #1
0
 function getNotices($offset, $limit, $ids)
 {
     if (empty($ids)) {
         $this->error = "El usuario " . $this->alumno->nickname . " no ha publicado nada en " . $this->group->nickname;
         return;
     }
     $total = $offset + $limit;
     for ($i = $offset; $i < $total; $i++) {
         $idsFinal[] = $ids[$i];
     }
     $notices = Notice::multiGet('id', $idsFinal);
     return $notices;
 }
 function getNotices()
 {
     $notices = array();
     $stream = new CommentByUserNoticeStream($userId);
     $notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, $this->since_id, $this->max_id);
     while ($notice->fetch()) {
         $notices[] = clone $notice;
     }
     $replyNoticeIds = array();
     foreach ($notices as $notice) {
         $reply_toId = $notice->reply_to;
         if (!empty($reply_toId)) {
             $replyNoticeIds[] = $notice->reply_to;
         }
     }
     $replyNotice = Notice::multiGet('id', $replyNoticeIds);
     while ($replyNotice->fetch()) {
         $replyNoticeArray[] = clone $replyNotice;
     }
     $this->m_notices = new ArrayWrapper($notices);
     $this->m_replyNotices = new ArrayWrapper($replyNoticeArray);
 }
예제 #3
0
    print "You must provide a file ID.\n";
    exit(1);
}
$verbose = have_option('v', 'verbose');
if (!have_option('y', 'yes')) {
    try {
        $filename = $file->getFilename();
    } catch (Exception $e) {
        $filename = '(remote file or no filename)';
    }
    print "About to PERMANENTLY delete file ({$filename}) with id=={$file->id}) AND its related notices. Are you sure? [y/N] ";
    $response = fgets(STDIN);
    if (strtolower(trim($response)) != 'y') {
        print "Aborting.\n";
        exit(0);
    }
}
print "Finding notices...\n";
try {
    $ids = File_to_post::getNoticeIDsByFile($file);
    $notice = Notice::multiGet('id', $ids);
    while ($notice->fetch()) {
        print "Deleting notice {$notice->id}" . ($verbose ? ": {$notice->content}\n" : "\n");
        $notice->delete();
    }
} catch (NoResultException $e) {
    print "No notices found with this File attached.\n";
}
print "Deleting File object together with possibly locally stored copy.\n";
$file->delete();
print "DONE.\n";
예제 #4
0
 function showContent()
 {
     $this->elementStart('div', 'qna-full-question');
     $this->raw($this->question->asHTML());
     $answer = $this->question->getAnswers();
     $this->elementStart('div', 'qna-full-question-answers');
     $answerIds = array();
     // @fixme use a filtered stream!
     if (!empty($answer)) {
         while ($answer->fetch()) {
             $answerIds[] = $answer->getNotice()->id;
         }
     }
     if (count($answerIds) > 0) {
         $notice = Notice::multiGet('id', $answerIds);
         $nli = new NoticeList($notice, $this);
         $nli->show();
     }
     $user = common_current_user();
     if (!empty($user)) {
         $profile = $user->getProfile();
         $answer = QnA_Question::getAnswer($profile);
         if (empty($answer)) {
             $form = new QnanewanswerForm($this, $this->question, false);
             $form->show();
         }
     }
     $this->elementEnd('div');
     $this->elementEnd('div');
 }
예제 #5
0
 static function getStreamByIds($ids)
 {
     return Notice::multiGet('id', $ids);
 }
 /**
  * Get notices
  *
  * @return array notices
  */
 function getNotices()
 {
     $notices = array();
     if (empty($this->auth_user)) {
         $profile = null;
     } else {
         $profile = $this->auth_user->getProfile();
     }
     $stream = new ReplyNoticeStream($this->user->id, $profile);
     $notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, $this->since_id, $this->max_id);
     while ($notice->fetch()) {
         $notices[] = clone $notice;
     }
     if ($this->include_in_reply_to_status) {
         $replyNoticeIds = array();
         foreach ($notices as $notice) {
             $reply_toId = $notice->reply_to;
             if (!empty($reply_toId)) {
                 $replyNoticeIds[] = $notice->reply_to;
             }
         }
         $replyNotice = Notice::multiGet('id', $replyNoticeIds);
         while ($replyNotice->fetch()) {
             $replyNoticeArray[] = clone $replyNotice;
         }
         $this->replyNotices = new ArrayWrapper($replyNoticeArray);
     }
     return $notices;
 }
예제 #7
0
 function showJsonTimeline($notice)
 {
     $this->initDocument('json');
     $statuses = array();
     if (is_array($notice)) {
         //FIXME: make everything calling showJsonTimeline use only Notice objects
         $ids = array();
         foreach ($notice as $n) {
             $ids[] = $n->getID();
         }
         $notice = Notice::multiGet('id', $ids);
     }
     while ($notice->fetch()) {
         try {
             $twitter_status = $this->twitterStatusArray($notice);
             array_push($statuses, $twitter_status);
         } catch (Exception $e) {
             common_log(LOG_ERR, $e->getMessage());
             continue;
         }
     }
     $this->showJsonObjects($statuses);
     $this->endDocument('json');
 }
예제 #8
0
 /**
  * Class handler.
  *
  * @param array $args query arguments
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if (!common_logged_in()) {
         $this->clientError(_('Not logged in.'));
         return;
     }
     $user = common_current_user();
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         common_redirect(common_local_url('all', array('nickname' => $user->nickname)));
         return;
     }
     $idGroup = $this->trimmed('idGroup');
     $token = $this->trimmed('token-' . $idGroup);
     if (!$token || $token != common_session_token()) {
         $this->clientError(_('There was a problem with your session token. Try again, please.'));
         return;
     }
     if ($this->trimmed('submit-auto') != null) {
         $groupids = NotesPDF::getNoticeIDsInAGroupModeAuto($idGroup);
         $notices = Notice::multiGet('id', $groupids)->fetchAll();
         GenerarPDF::content($idGroup, $notices, 'Automáticos');
     } else {
         if ($this->trimmed('submit-custom') != null) {
             $tag = $this->trimmed('combo-tag') == 'Todos' ? '%' : $this->trimmed('combo-tag');
             $nick = $this->trimmed('combo-user') == 'Todos' ? '%' : $this->trimmed('combo-user');
             $grade = $this->trimmed('combo-grade') == 'Todos' ? '%' : $this->trimmed('combo-grade');
             $noticeIds = NotesPDF::getNoticesInModeCustom(array('idGroup' => $idGroup, 'tag' => $tag, 'nick' => $nick, 'grade' => $grade));
             $notices = Notice::multiGet('id', $noticeIds)->fetchAll();
             GenerarPDF::content($idGroup, $notices, 'Personalizados');
         } else {
             $this->showForm('Error al generar los apuntes. Inténtelo de nuevo en unos minutos.');
         }
     }
 }