Exemple #1
0
 /**
  * Get an interface to pick to which nodes the statistics apply.
  *
  * @return string HTML markup
  *
  * @access private
  */
 private function getSelectedNodesUI()
 {
     $db = AbstractDb::getObject();
     // Init values
     $html = '';
     $name = "selected_nodes[]";
     $user = User::getCurrentUser();
     if (!isset($user)) {
         throw new Exception(_('Access denied!'));
     } else {
         if (!$user->DEPRECATEDisSuperAdmin()) {
             throw new Exception(_('Access denied!'));
         }
     }
     if ($user->DEPRECATEDisSuperAdmin()) {
         $sql_join = '';
     } else {
         $user_id = $db->escapeString($user->getId());
         $sql_join = " JOIN node_stakeholders ON (nodes.node_id=node_stakeholders.node_id AND user_id='{$user_id}') ";
     }
     $selectedNodes = $this->getSelectedNodes();
     $sql = "SELECT nodes.node_id, nodes.name from nodes {$sql_join} WHERE 1=1 ORDER BY lower(nodes.node_id)";
     $userData['preSelectedObjects'] = $selectedNodes;
     $userData['sqlJoin'] = $sql_join;
     $userData['typeInterface'] = "select_multiple";
     $html .= Node::getSelectUI($name, $userData);
     return $html;
 }
 /**
  * Shows the administration interface for ContentGroupElement
  *
  * @param string $subclass_admin_interface HTML code to be added after the
  *                                         administration interface
  *
  * @return string HTML code for the administration interface
  */
 public function getAdminUI($subclass_admin_interface = null, $title = null)
 {
     $db = AbstractDb::getObject();
     // Init values
     $html = '';
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<fieldset class='admin_element_group'>\n";
     $html .= "<legend>" . sprintf(_("%s %d display conditions"), get_class($this), $this->getDisplayOrder()) . "</legend>\n";
     $allowed_node_rows = null;
     $html .= "<ul class='admin_element_list'>\n";
     /* display_order */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>Display order: </div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "content_group_element_" . $this->id . "_display_order";
     $html .= "<input type='text' name='{$name}' value='" . $this->getDisplayOrder() . "' size='2'>\n";
     $html .= _("(Ignored if display type is random)") . "\n";
     $html .= "</div>\n";
     $html .= "</li>\n";
     $html .= "<li class='admin_element_item_container'>\n";
     // valid_from_timestamp
     $title_str = _("Content can be displayed at any date if no start or end date is specified.  Warning:  If you do not specify a specific time of day, midnight is assumed.");
     $html .= "<a href=\"#\" title=\"{$title_str}\">" . _("Only display from") . "</a>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "content_group_element_" . $this->id . "_valid_from";
     $datetime_from = new DateTimeWD($this->getValidFromDate());
     $html .= DateTimeWD::getSelectDateTimeUI($datetime_from, $name, DateTimeWD::INTERFACE_DATETIME_FIELD, null);
     $html .= "</div>\n";
     // valid_until_timestamp
     $html .= "<div class='admin_element_label'>until</div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $name = "content_group_element_" . $this->id . "_valid_until";
     $datetime_untill = new DateTimeWD($this->getValidUntilDate());
     $html .= DateTimeWD::getSelectDateTimeUI($datetime_untill, $name, DateTimeWD::INTERFACE_DATETIME_FIELD, null);
     $html .= "</div>\n";
     if (!$datetime_from->isEmpty() && $datetime_from->getTimestamp() > time()) {
         $html .= "<div class=warningmsg>Element not yet displayed</div>\n";
     }
     if (!$datetime_untill->isEmpty() && $datetime_untill->getTimestamp() < time()) {
         $html .= "<div class=warningmsg>Element has expired</div>\n";
     }
     $html .= "</li>\n";
     /* content_group_element_has_allowed_nodes */
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("Only display at node(s):") . _(" (DEPRECATED should use NodeGroups instead)") . "</div>\n";
     $html .= "<ul class='admin_element_list'>\n";
     $sql = "SELECT * FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='{$this->id}'";
     $db->execSql($sql, $allowed_node_rows, false);
     if ($allowed_node_rows != null) {
         foreach ($allowed_node_rows as $allowed_node_row) {
             $node = Node::getObject($allowed_node_row['node_id']);
             $html .= "<li class='admin_element_item_container'>\n";
             $html .= "<div class='admin_element_data'>\n";
             $html .= "" . $node->GetId() . ": " . $node->GetName() . "";
             $html .= "</div>\n";
             $html .= "<div class='admin_element_tools'>\n";
             $name = "content_group_element_" . $this->id . "_allowed_node_" . $node->GetId() . "_remove";
             $html .= "<input type='submit' name='{$name}' value='" . _("Remove") . "'>";
             $html .= "</div>\n";
             $html .= "</li>\n";
         }
     }
     $html .= "<li class='admin_element_item_container'>\n";
     $userDataNode['additionalWhere'] = "AND node_id NOT IN (SELECT node_id FROM content_group_element_has_allowed_nodes WHERE content_group_element_id='{$this->id}')";
     $name = "content_group_element_{$this->id}_new_allowed_node";
     $html .= Node::getSelectUI($name, $userDataNode);
     $name = "content_group_element_{$this->id}_new_allowed_node_submit";
     $html .= "<input type='submit' name='{$name}' value='" . _("Add new allowed node") . "'>";
     $html .= "</li'>\n";
     $html .= "</ul>\n";
     $html .= _("(Content can be displayed at ANY node unless one or more nodes are selected)") . "\n";
     $html .= "</li>\n";
     $html .= "</fieldset>\n";
     $html .= "</li>\n";
     /* displayed_content_id */
     $html .= "<li class='admin_element_item_container'>\n";
     if (empty($this->content_group_element_row['displayed_content_id'])) {
         $html .= "<div class='errormsg'>Sorry, display element is missing.</div>\n";
         /*        	$html .= "<fieldset class='admin_element_group'>\n";
                    $html .= "<legend>"._("Add a new displayed content OR select an existing one")."</legend>\n";
                    $html .= self :: getNewContentUI("content_group_element_{$this->id}_new_displayed_content")."<br>";
                    $html .= self :: getSelectExistingContentUI("content_group_element_{$this->id}_new_displayed_existing_element", "AND content_id != '$this->id'");
                    $html .= "</fieldset>\n";*/
     } else {
         $displayed_content = self::getObject($this->content_group_element_row['displayed_content_id']);
         $html .= $displayed_content->getAdminUI(null, sprintf(_("%s %d displayed content (%s)"), get_class($this), $this->getDisplayOrder(), get_class($displayed_content)));
         /*$html .= "<div class='admin_element_tools'>\n";
           $name = "content_group_element_{$this->id}_erase_displayed_content";
           $html .= "<input type='submit' name='$name' value='"._("Delete")."'>";
           $html .= "</div>\n";*/
     }
     $html .= "</li>\n";
     $html .= $subclass_admin_interface;
     return parent::getAdminUI($html, $title);
 }
         $node = Node::getObject($node_id);
         Node::setCurrentNode($node);
         $html .= "<h1>" . _("Showing preview as it would appear at ") . $node->getName() . "</h1><br><br>";
     }
     if (!empty($_REQUEST['debug'])) {
         $common_input .= "<input type='hidden' name='debug' value='true'>";
     }
     $common_input .= "<input type='hidden' name='object_id' value='" . $object->GetId() . "'>";
     $common_input .= "<input type='hidden' name='object_class' value='" . get_class($object) . "'>";
     $common_input .= "<input type='hidden' name='node_id' value='" . $node_id . "'>";
     $html .= "<form action='" . GENERIC_OBJECT_ADMIN_ABS_HREF . "' target='_top' method='post'>";
     $html .= $common_input;
     $name = "node_id";
     $html .= _("Node");
     $html .= ": ";
     $html .= Node::getSelectUI($name);
     if (method_exists($object, "getUserUI")) {
         $ui->addContent('main_area_middle', $object, 1);
     }
     $html .= "<input type='hidden' name='action' value='preview'>";
     $html .= "<input type='submit' name='preview_submit' value='" . _("Preview") . " " . get_class($object) . "'>";
     $html .= '</form>';
     $html .= "<form action='" . GENERIC_OBJECT_ADMIN_ABS_HREF . "' method='post'>";
     $html .= $common_input;
     $html .= "<input type='hidden' name='action' value='edit'>";
     $html .= "<input type=submit name='edit_submit' value='" . _("Edit") . " " . get_class($object) . "'>";
     $html .= '</form>';
     break;
 case "delete":
     // Gets called only if no JavaScript was enabled in the browser
     if ($object->delete($errmsg) == true) {
Exemple #4
0
 /** Get an interface to deal with missing nodes.  If the user has the permissions, he will be asked to create a new node for that gateway id, or assign that gateway id to an existing node.
  * @param $gwId The unknown gwId
  * @return html markup
  */
 public static function getStealOrCreateNewUI($gwId)
 {
     $permissionArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), null);
     $permissionArray[] = array(Permission::P('NODE_PERM_EDIT_GATEWAY_ID'), null);
     Security::requireAnyPermission($permissionArray);
     $db = AbstractDb::getObject();
     $html = '';
     $allowedNetworks = Security::getObjectsWithPermission(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'));
     $allowedNodes = Security::getObjectsWithPermission(Permission::P('NODE_PERM_EDIT_GATEWAY_ID'));
     $html .= "<p>" . _("Here is what you can do to fix this:") . "</p>\n";
     $html .= "<ul>\n";
     if ($allowedNetworks) {
         //Add a new node for unknown node id
         $html .= "<li>" . sprintf(_("You can create a new node with %s as it's associated gateway id.  This is typical for new installations."), $gwId) . "<br/>\n";
         $networkAdditionalWhere = " AND (FALSE\n";
         foreach ($allowedNetworks as $network) {
             $idStr = $db->escapeString($network->getId());
             $networkAdditionalWhere .= " OR network_id='{$idStr}'\n";
         }
         $networkAdditionalWhere .= ")\n";
         $userData['preSelectedObject'] = null;
         $userData['allowEmpty'] = true;
         $userData['additionalWhere'] = $networkAdditionalWhere;
         $name = "{$gwId}_new_node_network";
         $networkSelectUI = Network::getSelectUI($name, $userData);
         $html .= sprintf(_("Add a new node in %s"), $networkSelectUI) . " \n";
         $name = "{$gwId}_new_node_submit";
         $value = _("Add node");
         $html .= "<input type='submit' size='10' name='{$name}' value='{$value}'>\n";
         $html .= "</li>\n";
     }
     if ($allowedNetworks || $allowedNodes) {
         //"Steal" an existing node for this ID (typically for hardware replacement)
         $html .= "<li>" . sprintf(_("You can \"steal\" an existing node.  The node's gateway id will be replaced with %s.  This is typical when replacing hardware."), $gwId) . "<br/>\n";
         if ($allowedNetworks) {
             $additionalWhere = $networkAdditionalWhere;
         } else {
             $additionalWhere = " AND (FALSE\n";
             foreach ($allowedNetworks as $network) {
                 $idStr = $db->escapeString($node->getId());
                 $additionalWhere .= " OR node_id='{$idStr}'\n";
             }
             $additionalWhere .= ")\n";
         }
         $userData['preSelectedObject'] = null;
         $userData['allowEmpty'] = true;
         $userData['additionalWhere'] = $additionalWhere;
         $name = "{$gwId}_steal_node";
         $html .= Node::getSelectUI($name, $userData);
         $name = "{$gwId}_steal_node_submit";
         $value = _("Steal node");
         $html .= "<input type='submit' size='10' name='{$name}' value='{$value}'>\n";
         $html .= "</li>\n";
     }
     $html .= "</ul>\n";
     return $html;
 }