コード例 #1
0
ファイル: users.php プロジェクト: kjwill2499/CodingDojo
 public function show($user_id = null)
 {
     if ($user_id == null) {
         $user_id = $this->session->userdata('user_id');
     }
     $profileData = $this->User->get_user_by_id($user_id);
     $messages = $this->Message->get_all_by_user_id($user_id);
     $messageThread = new MessageList();
     foreach ($messages as $message) {
         $messageThread->message_ids[] = $message['id'];
         $message[$message['id']] = new UserMessage($message);
         $messageThread->addMessage($message[$message['id']]);
     }
     if ($messageThread->message_ids != null) {
         $comments = $this->Comment->get_all_by_message_ids($messageThread->message_ids);
         // var_dump($messageThread->message_ids);
         // var_dump($comments);
         foreach ($comments as $comment) {
             $c[$comment['id']] = new UserComment($comment);
             $message[$comment['message_id']]->addComment($c[$comment['id']]);
         }
     }
     $viewData['messageThread'] = $messageThread;
     $viewData['profileData'] = $profileData;
     $viewData['sessionToken'] = array('user_id' => $this->session->userdata('user_id'), 'level' => $this->session->userdata('level'));
     $viewData['errors'] = $this->session->flashdata('errors');
     // error_log('this is the vewData =>' . implode($viewData) . ' and profileData =>' . implode(', ', $profileData));
     $this->load->view('users/show', $viewData);
 }
コード例 #2
0
ファイル: SecureWidgets.php プロジェクト: clrh/mediawiki
 /**
  * Parser Function #widget
  */
 public function pfnc_widget(&$parser, $_name = null)
 {
     if (empty($_name)) {
         $msg = new MessageList();
         $msg->pushMessageById(self::NAME . '-missing-name');
         return $this->handleError($msg);
     }
     $params = func_get_args();
     array_shift($params);
     # $parser
     array_shift($params);
     # $name
     // make sure we are not tricked
     $name = $this->makeSecureName($_name);
     // get Factory istance
     $factory = MW_WidgetFactory::gs();
     // try building a widget from the provided name
     $widget = $factory->newFromWidgetName($name);
     if (!$widget instanceof Widget) {
         return $this->handleError($widget);
     }
     // render the widget with the provided parameters
     // TODO change to 'borg' pattern
     $renderer = MW_WidgetRenderer::gs();
     $output = $renderer->render($widget, $params);
     if (!is_string($output)) {
         return $this->handleError($output);
     }
     return array($output, 'noparse' => true, 'isHTML' => true);
 }
コード例 #3
0
 /**
  * Fetches a widget's code from the external Repository
  * 
  * @param $name string Name of the widget
  * @return $code mixed
  */
 protected function fetchFromRepository(&$name)
 {
     $msgs = new MessageList();
     // default feed
     $feed = new RepositoryFeed();
     $result = $feed->fetch();
     if ($result === false) {
         $msgs->pushMessageById(self::NAME . '-error-feed');
         return $msgs;
     }
     $_name = strtolower($name);
     $widgetLocator = $feed->getWidgetLocatorByName($_name);
     if (!$widgetLocator instanceof WidgetLocator) {
         $msgs->pushMessageById(self::NAME . '-widget-not-found', array($name));
         return $msgs;
     }
     $url = $widgetLocator->codelink;
     $code = $this->wget($url);
     if ($code === false) {
         $msgs->pushMessageById(self::NAME . '-error-code-fetch', array($name));
         return $msgs;
     }
     // if we got lucky, save it to the trans-cache
     $this->saveInTransCache($name, $code);
     return $code;
 }
コード例 #4
0
ファイル: WidgetFactory.php プロジェクト: clrh/mediawiki
 /**
  * Go through all registered code store
  * 
  * @param $name string
  * @return $obj mixed Widget / MW_SecureWidgetsMessageList
  */
 public function newFromWidgetName(&$name)
 {
     $this->fetchOtherStores();
     $msgs = new MessageList();
     foreach ($this->codeStore as $store) {
         $store->setName($name);
         $rawCode = $store->getCode();
         if (is_string($rawCode)) {
             $code = self::extractCode($rawCode);
             if ($code === false) {
                 $msgs->pushMessageById(self::NAME . '-nocode');
                 continue;
             }
             return new Widget($name, $code);
         } else {
             $msgs->insertMessages($rawCode);
         }
     }
     //foreach
     // error
     return $msgs;
 }
コード例 #5
0
ファイル: WidgetRenderer.php プロジェクト: clrh/mediawiki
 /**
  * @return $obj mixed String with result OR MessageList object instance in case of errors
  */
 public static function render(&$widget, &$params)
 {
     // error stack object
     $msgs = new MessageList();
     $code = $widget->getCode();
     $name = $widget->getName();
     // extract parameters from widget template
     $tp = WidgetParameters::newFromTemplate($code);
     // prepare the input variables
     $ip = WidgetParameters::newFromParamList($params);
     // Case 1: template does not have parameters
     //         Don't make waves even in the case where
     //         input variables are provided where none are required...
     if ($tp->isEmpty()) {
         return $code;
     }
     // Case 2: template has parameters but no input variables provided
     if ($ip->isEmpty()) {
         $msg = new MessageList();
         return $msg->pushMessageById(self::NAME . '-missing-inputs', array($name));
     }
     // Case 3: template specifies parameter types and input variables do not match
     foreach ($tp as $index => $e) {
         if (!isset($e['n'])) {
             throw new Exception(__METHOD__ . ": name parameter missing in template");
         }
         if (!isset($e['t'])) {
             throw new Exception(__METHOD__ . ": type parameter missing in template");
         }
         $patt = $e['r'];
         $name = $e['n'];
         $type = $e['t'];
         $value = null;
         // make sure we have an input variable that corresponds
         // the a required template parameter
         if (isset($ip[$name])) {
             $value = $ip[$name]['v'];
         } else {
             // is there a default value then??
             if (isset($e['d'])) {
                 $value = $e['d'];
             } else {
                 $msgs->pushMessageById(self::NAME . '-missing-input', array($name, $type));
                 continue;
             }
         }
         $result = TypeChecker::checkParam($type, $value);
         if ($result === null) {
             $msgs->pushMessageById(self::NAME . '-unsupported-type', array($name, $type));
             continue;
         }
         if ($result === false) {
             $msgs->pushMessageById(self::NAME . '-type-mismatch', array($name, $type));
             continue;
         }
         // everything looks OK - add value to template parameters list
         $tp->setParam($index, 'v', $value);
     }
     //foreach
     // if we have error messages, exit now
     if (!$msgs->isEmpty()) {
         return $msgs;
     }
     // Perform replacements in template and return the resulting code
     return WidgetParameters::doReplacementsInWidgetTemplate($widget, $tp);
 }
コード例 #6
0
ファイル: index.php プロジェクト: sekure/nameid
require_once "lib/config.inc.php";
require_once "lib/html.inc.php";
require_once "lib/json.inc.php";
require_once "lib/messages.inc.php";
require_once "lib/request.inc.php";
require_once "lib/session.inc.php";
require_once "libauth/authenticator.inc.php";
require_once "libauth/namecoin_rpc.inc.php";
require_once "libauth/namecoin_interface.inc.php";
/* Construct basic worker classes.  */
$session = new Session($sessionName);
$rpc = new HttpNamecoin($rpcHost, $rpcPort, $rpcUser, $rpcPassword);
$nc = new NamecoinInterface($rpc, $namePrefix);
$req = new RequestHandler();
$html = new HtmlOutput();
$msg = new MessageList($html);
/* Set status which may be changed later to show different pages.  */
$status = "unknown";
/**
 * Try to perform a user login request.
 */
function tryLogin()
{
    global $req, $session, $msg, $nc;
    global $status;
    global $serverUri;
    if ($status === "unknown" && $req->check("action")) {
        $action = $req->getString("action");
        switch ($action) {
            case "login":
                if ($req->getSubmitButton("cancel")) {
コード例 #7
0
ファイル: MessageContent.php プロジェクト: AxelPanda/ibos
 private function addMessageList($data, $fromUid)
 {
     if (!$data["content"] || !is_array($data["users"]) || !$fromUid) {
         return false;
     }
     $list["fromuid"] = $fromUid;
     $list["title"] = isset($data["title"]) ? StringUtil::filterCleanHtml($data["title"]) : StringUtil::filterCleanHtml(StringUtil::cutStr($data["content"], 20));
     $list["usernum"] = count($data["users"]);
     $list["type"] = is_numeric($data["type"]) ? $data["type"] : (2 == $list["usernum"] ? 1 : 2);
     $list["minmax"] = $this->getUidMinMax($data["users"]);
     $list["mtime"] = $data["mtime"];
     $list["lastmessage"] = serialize(array("fromuid" => $fromUid, "content" => StringUtil::filterDangerTag($data["content"])));
     $listRec = MessageList::model()->findByAttributes(array("type" => $list["type"], "minmax" => $list["minmax"]));
     $listId = !empty($listRec) ? $listRec["listid"] : null;
     if ($list["type"] == 1 && $listId) {
         $_list["usernum"] = $list["usernum"];
         $_list["lastmessage"] = $list["lastmessage"];
         $saved = MessageList::model()->updateAll($_list, "`type` = :type AND `minmax` = :minmax AND `listid`=:listid", array(":type" => $list["type"], ":minmax" => $list["minmax"], ":listid" => $listId));
         if (!$saved) {
             $listId = false;
         }
     } else {
         $listId = MessageList::model()->add($list, true);
     }
     return $listId;
 }
コード例 #8
0
ファイル: functions.php プロジェクト: ktharmabalan/gmail
/**
 * Get list of Messages in user's mailbox.
 *
 * @param  Google_Service_Gmail $service Authorized Gmail API instance.
 * @param  string $userId User's email address. The special value 'me'
 * can be used to indicate the authenticated user.
 * @return array Array of Messages.
 */
function message_list($service, $maxResults)
{
    $user = '******';
    $pageToken = NULL;
    $messages = array();
    $opt_param = array();
    $opt_param['includeSpamTrash'] = false;
    // $opt_param['maxResults'] = $maxResults;
    $opt_param['labelIds'] = 'INBOX';
    $messagesResponse = $service->users_messages->listUsersMessages($user, $opt_param);
    if ($messagesResponse->getMessages()) {
        $messageList = new MessageList();
        foreach ($messagesResponse->getMessages() as $message) {
            $messageList->addMessage(new MessageListItem($message->getThreadId(), $message->getId()));
        }
        return $messageList;
    }
}