예제 #1
0
 /** Get the selected Content object.
  * @param $user_prefix A identifier provided by the programmer to recognise it's generated form
  * @return the Content object
  */
 static function processSelectContentUI($user_prefix)
 {
     $name = "{$user_prefix}";
     if (!empty($_REQUEST[$name])) {
         return Content::getObject($_REQUEST[$name]);
     } else {
         return null;
     }
 }
 /**
  * Processes the input of the administration interface for ContentGroupElement
  *
  * @return void
  */
 public function processAdminUI()
 {
     $errmsg = "";
     // display_order
     $name = "profile_template_field_{$this->_id}_display_order";
     $this->setDisplayOrder($_REQUEST[$name]);
     // display_label_content_id
     if (empty($this->profile_template_field_row['display_label_content_id'])) {
         // Could be either a new content or existing content ( try both successively )
         $display_label_content = Content::processNewContentUI("profile_template_field_{$this->_id}_new_display_label_content");
         if ($display_label_content != null) {
             $this->replaceDisplayLabelContent($display_label_content);
         }
     } else {
         $display_label_content = Content::getObject($this->profile_template_field_row['display_label_content_id']);
         $name = "profile_template_field_{$this->_id}_erase_display_label_content";
         if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) {
             $this->replaceDisplayLabelContent(null);
         } else {
             $display_label_content->processAdminUI();
         }
     }
     // admin_label_content_id
     if (empty($this->profile_template_field_row['admin_label_content_id'])) {
         // Could be either a new content or existing content ( try both successively )
         $admin_label_content = Content::processNewContentUI("profile_template_field_{$this->_id}_new_admin_label_content");
         if ($admin_label_content != null) {
             $this->replaceAdminLabelContent($admin_label_content);
         }
     } else {
         $admin_label_content = Content::getObject($this->profile_template_field_row['admin_label_content_id']);
         $name = "profile_template_field_{$this->_id}_erase_admin_label_content";
         if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) {
             $this->replaceAdminLabelContent(null);
         } else {
             $admin_label_content->processAdminUI();
         }
     }
     // semantic_id
     $name = "profile_template_field_{$this->_id}_semantic_id";
     $this->setSemanticId($_REQUEST[$name]);
     $this->refresh();
 }
예제 #3
0
 /**
  * Detects if a user is owner of a ContentGroupElement
  *
  * Override the method in Content.
  *
  * The owners of the content element are always considered to be the ContentGroup's
  *
  * @param object $user User object: the user to be tested.
  *
  * @return bool True if the user is a owner, false if he isn't or if the user is null
  */
 public function DEPRECATEDisOwner($user)
 {
     $content_group = Content::getObject($this->content_group_element_row['content_group_id']);
     return $content_group->DEPRECATEDisOwner($user);
 }
예제 #4
0
 /**
  * Display the narrative
  *
  * @param string $user The user who's narrative you want to grab
  *
  * @return the archive page HTML
  */
 public function displayNarrative(User $user)
 {
     $db = AbstractDb::getObject();
     // Init values
     $html = "";
     $rows = null;
     /**
      * @internal Debug values user_id = 8a90b1ea56cf27a0c61f9304da73bcd5
      * @internal PL: 3a3ea73dd2e2d03729e62b95d2574fc6
      */
     $sql = "SELECT * FROM (SELECT DISTINCT ON (content_group_element_id) content_group_element_id, first_display_timestamp FROM content_display_log AS cdl JOIN content_group_element AS cge ON (cdl.content_id = cge.content_group_element_id) JOIN content ON (content.content_id = cge.content_group_id) where user_id = '{$user->getId()}' AND cge.content_group_id = '{$this->getId()}' AND content.content_type = 'PatternLanguage') AS patterns ORDER BY first_display_timestamp";
     $db->execSql($sql, $rows, false);
     if ($rows) {
         foreach ($rows as $row) {
             $cge = Content::getObject($row['content_group_element_id']);
             $cge->setLoggingStatus(false);
             $html .= $cge->getUserUI() . "<p>";
         }
     }
     return $html;
 }
예제 #5
0
 /** Retreives the user interface of this object.  Anything that overrides this method should call the parent method with it's output at the END of processing.
  * @return The HTML fragment for this interface */
 public function getUserUI()
 {
     $real_node = Node::getCurrentRealNode();
     //For production
     //$real_node = Node::getCurrentNode();//For testing
     $node = Node::getCurrentNode();
     $formHtml = null;
     if ($real_node) {
         $formHtml .= "<form action='" . BASE_URL_PATH . "content/ShoutBox/add_message.php'>\n";
         $formHtml .= "<input type='hidden' name='shoutbox_id' value='" . $this->getId() . "'/>\n";
         //$html .= "destination_url: ";pretty_print_r($_SERVER);
         $maxShoutChars = $this->getMaxShoutChars();
         $shoutFieldSize = $this->getShoutFieldSize();
         if ($maxShoutChars > 0) {
             $max_size = "maxlength='{$maxShoutChars}'";
             $maxShoutChars <= $shoutFieldSize ? $size = "size='{$maxShoutChars}'" : ($size = "size='{$shoutFieldSize}'");
         } else {
             $max_size = null;
             $size = "size='{$shoutFieldSize}'";
         }
         $formHtml .= "<input type='hidden' name='node_id' value='" . $node->getId() . "'/>\n";
         $formHtml .= "<input type='text' name='shout_text' id='shout_text' {$size} {$max_size} value=''/>\n";
         $onclick_content = $this->getOnClickContent();
         if ($onclick_content) {
             $onclick = "onclick=\"" . $onclick_content->getString() . "\"";
         } else {
             $onclick = null;
         }
         $formHtml .= "<input type='submit' name='shout_submit' {$onclick} value='" . _("Shout!") . "'>\n";
         $formHtml .= "</form>\n";
     } else {
         $formHtml .= "<p>" . _("Sorry, you must be at a hotspot to use the shoutbox") . "</p>\n";
     }
     $html_main = '';
     $displayNumItems = $this->getDisplayNumItems();
     $db = AbstractDb::getObject();
     if ($node) {
         $node_id = $db->escapeString($node->getId());
         if ($displayNumItems > 0) {
             $limit = "LIMIT {$displayNumItems}";
             $heading = "<em>" . sprintf(_("Last %d messages:"), $displayNumItems) . "</em>";
         } else {
             $limit = null;
             $heading = null;
         }
         $sql = "SELECT *, EXTRACT(EPOCH FROM creation_date) as creation_date_php FROM content_shoutbox_messages WHERE origin_node_id='{$node_id}' ORDER BY creation_date DESC {$limit}\n";
         $db->execSql($sql, $rows, false);
         $html_main .= "<ul>";
         $html_main .= "<li>{$formHtml}</li>";
         if ($rows) {
             //$html_main .= $heading;
             foreach ($rows as $row) {
                 $user = User::getObject($row['author_user_id']);
                 $content = Content::getObject($row['message_content_id']);
                 $html_main .= "<li>";
                 $dateStr = "<span class='date'>" . strftime('%x', $row['creation_date_php']) . "</span>\n";
                 $html_main .= $dateStr . ' ' . $user->getListUI() . ": \n";
                 $html_main .= "<div class='message'>" . $content->getListUI() . "</div>\n";
                 $html_main .= "</li>";
             }
         }
         $html_main .= "</ul>";
     } else {
         $html_main .= "<p>" . _("Sorry, I am unable to determine your current node") . "</p>\n";
     }
     $this->setUserUIMainDisplayContent($html_main);
     //$this->setUserUIMainInteractionArea($formHtml);
     return Content::getUserUI();
 }
예제 #6
0
    foreach ($content_rows as $content_row) {
        $content = Content :: getObject($content_row['content_id']);
        if ($content->isDisplayableAt($node)) {
            $ui->addContent($content_row['display_area'], $content, $content_row['display_order']);
        }
    }
}*/
// Get all user content
$content_rows = array();
if ($current_user) {
    $user_id = $db->escapeString($current_user->getId());
    $sql = "SELECT content_id FROM user_has_content WHERE user_id = '{$user_id}' ORDER BY subscribe_timestamp DESC";
    $db->execSql($sql, $content_rows, false);
    if ($content_rows) {
        foreach ($content_rows as $content_row) {
            $content = Content::getObject($content_row['content_id']);
            if ($content->isDisplayableAt($node)) {
                $ui->addContent('main_area_middle', $content);
            }
        }
    }
}
if ($showMoreLink) {
    $link_html = "<a href='{$base_ssl_path}content/?node_id={$currentNodeId}'>" . _("Show all available contents for this hotspot") . "</a>\n";
    $ui->addContent('main_area_middle', $link_html);
}
$ui->display();
/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
예제 #7
0
 /**
  * Process admin interface of this object
  *
  * @return void
  */
 public function processAdminUI()
 {
     Security::requirePermission(Permission::P('SERVER_PERM_EDIT_ROLES'), Server::getServer());
     $db = AbstractDb::getObject();
     $errmsg = "";
     // role_id
     $value = htmlspecialchars($this->getId(), ENT_QUOTES);
     // role_description_content_id
     if (empty($this->_row['role_description_content_id'])) {
         $name = "role_{$this->id}_description_new";
         $description = Content::processNewContentUI($name);
         if ($description != null) {
             $description_id = $description->GetId();
             $db->execSqlUpdate("UPDATE roles SET role_description_content_id = '{$description_id}' WHERE role_id = '{$this->id}'", FALSE);
         }
     } else {
         $description = Content::getObject($this->_row['role_description_content_id']);
         $name = "role_{$this->id}_description_erase";
         if (!empty($_REQUEST[$name]) && $_REQUEST[$name] == true) {
             $db->execSqlUpdate("UPDATE roles SET role_description_content_id = NULL WHERE role_id = '{$this->id}'", FALSE);
             $description->delete($errmsg);
         } else {
             $description->processAdminUI();
         }
     }
     // Permissions
     $permissionsArray = Permission::getPermissions(array('stakeholderTypeId' => $this->_row['stakeholder_type_id']));
     $idStr = $db->escapeString($this->getId());
     $stakeholderTypeIdStr = $db->escapeString($this->_row['stakeholder_type_id']);
     $sql = "SELECT permissions.permission_id, stakeholder_type_id, role_id FROM permissions LEFT JOIN role_has_permissions  ON (role_has_permissions.permission_id = permissions.permission_id AND role_id = '{$idStr}') WHERE stakeholder_type_id='{$stakeholderTypeIdStr}'";
     $db->execSql($sql, $permission_rows, false);
     $sql = null;
     if ($permission_rows) {
         foreach ($permission_rows as $row) {
             $permissionIdStr = $db->escapeString($row['permission_id']);
             $name = "role_{$this->id}_permission_" . htmlspecialchars($row['permission_id'], ENT_QUOTES) . "_included";
             if (empty($row['role_id']) && !empty($_REQUEST[$name]) && $_REQUEST[$name] == 'included') {
                 $sql = "INSERT INTO role_has_permissions (permission_id, role_id) VALUES ('{$permissionIdStr}','{$idStr}');\n";
             } else {
                 if (!empty($row['role_id']) && empty($_REQUEST[$name])) {
                     $sql = "DELETE FROM role_has_permissions WHERE permission_id='{$permissionIdStr}' AND role_id='{$idStr}';\n";
                 } else {
                     //echo "Do nothing for {$row['permission_id']}<br/>";
                 }
             }
         }
     }
     if ($sql) {
         $db->execSqlUpdate("BEGIN;\n{$sql}COMMIT;", false);
     }
     $this->refresh();
 }
예제 #8
0
 function getAllContent()
 {
     $db = AbstractDb::getObject();
     $retval = array();
     $content_rows = null;
     $sql = "SELECT * FROM user_has_content WHERE user_id='{$this->id}' ORDER BY subscribe_timestamp";
     $db->execSql($sql, $content_rows, false);
     if ($content_rows != null) {
         foreach ($content_rows as $content_row) {
             $retval[] = Content::getObject($content_row['content_id']);
         }
     }
     return $retval;
 }
예제 #9
0
 /**
  * Add the content marked "everywhere" from both the current node and the
  * current network.
  *
  * @return void
  */
 private function addEverywhereContent()
 {
     $db = AbstractDb::getObject();
     // Get all network content and node "everywhere" content
     $content_rows = null;
     $node = Node::getCurrentNode();
     // Get all the parent objects of the node
     if ($node) {
         $parents = HotspotGraph::getAllParents($node);
     } else {
         $parents = array(Network::getCurrentNetwork()->getHgeId());
     }
     $first = $db->escapeString(array_shift($parents));
     $sql_from = "(SELECT content_id, display_area, display_order, subscribe_timestamp \n        \t\t\tFROM hotspot_graph_element_has_content hgehc \n        \t\t\tWHERE hotspot_graph_element_id='{$first}' AND display_page='everywhere')";
     // Get the contents for all elements parents of and including the node, but exclude user subscribed content if user is known
     foreach ($parents as $parentid) {
         $parent_id = $db->escapeString($parentid);
         $sql_from .= " UNION (SELECT content_id, display_area, display_order, subscribe_timestamp \n        \t\t\tFROM hotspot_graph_element_has_content hgehc \n        \t\t\tWHERE hotspot_graph_element_id='{$parent_id}' AND display_page='everywhere')";
     }
     $sql = "SELECT * FROM ({$sql_from}) AS content_everywhere ORDER BY display_area, display_order, subscribe_timestamp DESC";
     $db->execSql($sql, $content_rows, false);
     if ($content_rows) {
         foreach ($content_rows as $content_row) {
             $content = Content::getObject($content_row['content_id']);
             if ($content->isDisplayableAt($node)) {
                 $this->addContent($content_row['display_area'], $content, $content_row['display_order']);
             }
         }
     }
 }
예제 #10
0
 /**
  * Retrieves the associated content field
  *
  * @return Content object
  *
  * @access public
  */
 public function getContentField()
 {
     $retval = null;
     if ($this->profile_field_row['content_id'] != null) {
         $retval = Content::getObject($this->profile_field_row['content_id']);
     }
     return $retval;
 }
예제 #11
0
// +-------------------------------------------------------------------+
/**
 * @package    WiFiDogAuthServer
 * @author     Benoit Grégoire
 * @copyright  2006 Technologies Coeus inc.
 * @version    Subversion $Id: $
 * @link       http://www.wifidog.org/
 */
/**
 * Load required files
 */
require_once dirname(__FILE__) . '/../../include/common.php';
require_once 'classes/Content.php';
if (!empty($_REQUEST['content_id'])) {
    $db = AbstractDb::getObject();
    $content = Content::getObject($_REQUEST['content_id']);
    $content_str = $content->getString();
    if ($content instanceof Stylesheet) {
        // Check if the HTTP request is asking if the file has been modified since a certain date.
        $last_modified_date = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : 0;
        if ($last_modified_date && $_SERVER['REQUEST_METHOD'] == "GET" && strtotime($last_modified_date) >= strtotime($content->getLastUpdateTimestamp())) {
            header("HTTP/1.1 304 Not Modified");
        } else {
            //headers to send to the browser before beginning the binary download
            header("Pragma: public");
            // Send last update date to proxy / cache the binary
            header("Last-Modified: " . gmdate("D, d M Y H:i:s", strtotime($content->getLastUpdateTimestamp())) . " GMT");
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Cache-Control: public");
            header('Content-Type: text/css');
            header('Accept-Ranges: bytes');
예제 #12
0
 /**
  * Generates an HTML SELECT element from an SQL result set
  *
  * @param $resultSet : The SQL result set
  * @param $primaryKeyField : The column to use the primary key
  * @param $displayField : The column to display to the user
  * @param $selectedPrimaryKey : Optional.  Which element should be selected by default, use null to select the first one
  * @param $userPrefix : An arbitrary prefix, chosen by the user, to guarantee unicity
  * @param $objectPrefix : An arbitrary prefix, chosen by the calling object, to guarantee unicity
  * @param $displayFieldIsLangstring
  * @param $allowNullValues, TRUE or FALSE
  * @param $nullCaptionString, string displayed in place of null values
  * @param $additionalSelectAttribute will be appended inside the select tag.  For example: "onclick='submit();'"
  * @return string The HTML SELECT element definition string
  */
 static function generateFromResultSet($resultSet, $primaryKeyField, $displayField, $selectedPrimaryKey, $userPrefix, $objectPrefix, $displayFieldIsLangstring, $allowNullValues, $nullCaptionString = ' - - - ', $additionalSelectAttribute)
 {
     $retval = "";
     $retval .= "<select id='{$userPrefix}{$objectPrefix}' name='{$userPrefix}{$objectPrefix}' {$additionalSelectAttribute}>\n";
     if ($allowNullValues === true) {
         $retval .= "<option value=''>{$nullCaptionString}</option>\n";
     }
     if (!empty($resultSet)) {
         foreach ($resultSet as $key => $value) {
             $retval .= "<option ";
             if ($value[$primaryKeyField] == $selectedPrimaryKey) {
                 $retval .= 'selected="selected" ';
             }
             if ($displayFieldIsLangstring === true) {
                 if (!empty($value[$displayField])) {
                     $langstring = Content::getObject($value[$displayField]);
                     if ($langstring->IsEmpty()) {
                         $nom = $value[$primaryKeyField] . _(" (Empty langstring, ID is displayed)");
                     } else {
                         $nom = $langstring->GetString();
                     }
                 } else {
                     $nom = $value[$primaryKeyField] . _(" (Empty langstring, ID is displayed)");
                 }
             } else {
                 $nom = $value[$displayField];
             }
             $nom = htmlentities($nom, ENT_QUOTES, 'UTF-8');
             $primary_key = htmlentities($value[$primaryKeyField], ENT_QUOTES, 'UTF-8');
             $retval .= "value='{$primary_key}'>{$nom}</option>\n";
         }
     } else {
         if ($allowNullValues === false) {
             echo "<h1>FormSelectGenerator::generateFromResultSet(): Error: No results found, NULL value not allowed</h1>\n";
         }
     }
     $retval .= "</select>\n";
     return $retval;
 }