Esempio n. 1
0
 /**
  * Retrieves the interface to assign stakeholders to objects
  *
  * @return string The HTML fragment for this interface
  *
  * @param $targetObject The Object on which the permssion applies (Network, Server, etc.)
  */
 public static function getAssignStakeholdersUI($targetObject)
 {
     require_once 'classes/Role.php';
     if (User::getCurrentUser()->DEPRECATEDisSuperAdmin()) {
         $listData = "";
         $db = AbstractDb::getObject();
         $object_class = get_class($targetObject);
         $table = strtolower($object_class) . '_stakeholders';
         $object_id = $db->escapeString($targetObject->getId());
         $sql = "SELECT * FROM {$table} JOIN roles USING (role_id) WHERE object_id = '{$object_id}';";
         $stakeholder_rows = null;
         $db->execSql($sql, $stakeholder_rows, false);
         if ($stakeholder_rows) {
             foreach ($stakeholder_rows as $stakeholder_row) {
                 $user = User::getObject($stakeholder_row['user_id']);
                 $role = Role::getObject($stakeholder_row['role_id']);
                 $roleStr = htmlspecialchars($role->getLabelStr());
                 $name = $object_id . "_stakeholder_" . $stakeholder_row['user_id'] . "_" . $stakeholder_row['role_id'] . "_remove";
                 $listDataContents = InterfaceElements::generateAdminSection("", $user->getListUI() . ' ' . $roleStr, InterfaceElements::generateInputSubmit($name, _("Remove stakeholder")));
                 $listData .= "<li class='admin_element_item_container node_owner_list'>" . $listDataContents . "</li>\n";
             }
         }
         $listData .= "<li class='admin_element_item_container'>";
         $listData .= Role::getSelectUI($object_id . "_new_stakeholder_role", array('stakeholderTypeId' => $object_class));
         $listData .= User::getSelectUserUI($object_id . "_new_stakeholder", $object_id . "_new_stakeholder_submit", _("Add stakeholder"));
         $listData .= "<br class='clearbr' /></li>\n";
         $html = "<ul id='node_owner_ul' class='admin_element_list'>\n" . $listData . "</ul>\n";
     }
     return $html;
 }
Esempio n. 2
0
 public function addBubbleTipToElement($element, $cookiePrefix, $text)
 {
     global $wgOut;
     $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('tipsbubble.css'), 'extensions/wikihow/interfaceelements', false));
     $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('interfaceelements/tipsbubble.js', 'common/jquery.cookie.js'), 'extensions/wikihow', false));
     $tmpl = new EasyTemplate(dirname(__FILE__));
     $tmpl->set_vars(array('text' => $text));
     InterfaceElements::addJSVars(array('bubble_target_id' => $element, 'cookieName' => $cookiePrefix . '_b'));
     $wgOut->addHTML($tmpl->execute('TipsBubble.tmpl.php'));
 }
Esempio n. 3
0
 function execute($par)
 {
     global $wgOut, $wgRequest, $wgUser, $wgParser;
     wfLoadExtensionMessages("TipsPatrol");
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if ($wgUser->isAnon() || self::isBlockedFromTipsPatrol($wgUser)) {
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->errorpage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     $this->skipTool = new ToolSkip("tiptool", "tipsandwarnings", "tw_checkout", "tw_checkout_user", "tw_id");
     if ($wgRequest->wasPosted()) {
         $wgOut->disable();
         $result = array();
         $tipId = $wgRequest->getVal('tipId');
         if ($wgRequest->getVal('coachTip')) {
             $this->coachResult($tipId, &$result);
         } elseif ($tipId != null && $wgRequest->getVal('skipTip')) {
             $this->logTip($tipId, self::TIP_ACTION_SKIP);
             $this->skipTool->skipItem($tipId);
             $this->skipTool->unUseItem($tipId);
         } elseif ($wgRequest->getVal('deleteTip')) {
             $articleId = $wgRequest->getVal('articleId');
             $tip = $wgRequest->getVal('tip');
             $this->deleteTip($tipId, $articleId, $tip);
         } elseif ($wgRequest->getVal('keepTip')) {
             //used to send to keepTip, but now we have an extra step: QG
             $articleId = $wgRequest->getVal('articleId');
             $tip = $wgRequest->getVal('tip');
             $this->logTip($tipId, self::TIP_ACTION_QG, '', $tip);
             $this->addToQG($tipId, $articleId, $tip, $result);
         }
         $this->getNextTip(&$result);
         echo json_encode($result);
         return;
     }
     $wgOut->setHTMLTitle(wfMsg('tipspatrol'));
     $wgOut->setPageTitle(wfMsg('tipspatrol'));
     $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('tipspatrol.css'), 'extensions/wikihow/tipsandwarnings', false));
     $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('tipspatrol.js'), 'extensions/wikihow/tipsandwarnings', false));
     $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('mousetrap.min.js,jquery.cookie.js'), 'extensions/wikihow/common', false));
     EasyTemplate::set_path(dirname(__FILE__));
     $vars = array();
     $vars['tip_skip_title'] = wfMsg('tip_skip_title');
     $vars['tip_keep_title'] = wfMsg('tip_keep_title');
     $vars['tip_delete_title'] = wfMsg('tip_delete_title');
     $wgOut->addHTML(EasyTemplate::html('TipsPatrol.tmpl.php', $vars));
     $bubbleText = "Only publish this tip if you can make it helpful, clear, and grammatically correct. Most tips should get deleted.";
     InterfaceElements::addBubbleTipToElement('tip_tip', 'tptrl', $bubbleText);
     $this->displayLeaderboards();
 }
 public function addBubbleTipToElement($element, $cookiePrefix, $text)
 {
     global $wgOut;
     $wgOut->addJSCode('jqck');
     //jQuery Cookie. Add as JS code so we don't have duplicate includes
     $wgOut->addCSSCode('tbc');
     // Tips Bubble CSS
     InterfaceElements::addJSVars(array('bubble_target_id' => $element, 'cookieName' => $cookiePrefix . '_b'));
     $wgOut->addHTML(HtmlSnips::makeUrlTags('js', array('interfaceelements/tipsbubble.js'), 'extensions/wikihow', false));
     $tmpl = new EasyTemplate(dirname(__FILE__));
     $tmpl->set_vars(array('text' => $text));
     $wgOut->addHTML($tmpl->execute('TipsBubble.tmpl.php'));
 }
Esempio n. 5
0
 /**
  * @todo Complete this
  */
 public static function getSelectDateTimeUI(DateTimeWD $datetime, $userPrefix, $interface_type, $id = "")
 {
     $html = "";
     switch ($interface_type) {
         case self::INTERFACE_DATE_SELECTOR:
             $html = "";
             break;
         case self::INTERFACE_DATETIME_SELECTOR:
             $html = "";
             break;
         case self::INTERFACE_DATETIME_FIELD:
             $str = $datetime->getIso8601FormattedString();
             $html = InterfaceElements::generateInputText($userPrefix, $str, $id);
             break;
     }
     return $html;
 }
 /**
  * Execute special page.  Only available to wikihow staff.
  */
 public function execute()
 {
     global $wgUser, $wgRequest, $wgOut, $wgLang, $wgMemc;
     if (!$this->userAllowed()) {
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     if ($wgRequest->wasPosted()) {
         switch ($wgRequest->getVal('action')) {
             case 'nextUser':
                 $this->nextUser();
                 break;
             case 'logMessage':
                 $wgOut->disable();
                 $toId = $wgRequest->getVal('toId');
                 $revId = $wgRequest->getVal('revId');
                 $message = $wgRequest->getVal('message');
                 $this->logMessage($wgUser->getId(), $toId, $revId, $message);
                 echo json_encode(array('stats' => $this->getStats()));
                 break;
             case 'switchTab':
                 $this->tabSwitch();
                 break;
             default:
                 break;
         }
         return;
     }
     $target = $wgRequest->getVal('target');
     if ($target) {
         $targetUser = User::newFromName($target);
         if ($targetUser->getId() > 0) {
             InterfaceElements::addJSVars($this->getOutputVariables($targetUser));
         }
     }
     if (!$wgMemc->get($this->cacheOk)) {
         $this->resetCache();
     }
     $wgOut->setPageTitle('Welcome Wagon');
     $wgOut->setHTMLTitle('Welcome Wagon');
     $tmpl = new EasyTemplate(dirname(__FILE__));
     $wgOut->addHTML($tmpl->execute('WelcomeWagon.tmpl.php'));
     $wgOut->addCSScode('diffc');
     $wgOut->addHTML(HtmlSnips::makeUrlTags('css', array('welcomewagon.css'), 'extensions/wikihow/WelcomeWagon', false));
     $wgOut->addHTML(HtmlSnips::makeUrlTags('js', array('welcomewagon.js'), 'extensions/wikihow/WelcomeWagon', false));
     InterfaceElements::addBubbleTipToElement('form-header', 'wwagon', 'No matter what happens keep the message positive and personalized.');
     $this->displayLeaderboards();
 }
Esempio n. 7
0
 /**
  * Retreives the admin interface of this object
  *
  * @return string The HTML fragment for this interface
  */
 public function getAdminUI()
 {
     Security::requirePermission(Permission::P('NETWORK_PERM_EDIT_NETWORK_CONFIG'), $this);
     require_once 'classes/InterfaceElements.php';
     // Init values
     $html = '';
     /*
      * Verify if an error message was registered before outputting the form
      */
     if (isset($this->errorMsg)) {
         $html .= "<div class='errormsg'>" . $this->errorMsg . "</div>";
     }
     /*
      * Begin with admin interface
      */
     $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n";
     $html .= "<legend>" . _("Network management") . "</legend>\n";
     $html .= "<ul class='admin_element_list'>\n";
     /*
      * Content management
      */
     $html .= parent::getContentAdminUI();
     /*
      * Network information
      */
     $html_network_information = array();
     // network_id
     $title = _("Network ID");
     $data = htmlspecialchars($this->getId(), ENT_QUOTES);
     $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_id", $title, $data);
     // name
     $title = _("Network name");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_name", $this->getName(), "network_name_input");
     $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_name", $title, $data);
     // creation_date
     $title = _("Network creation date");
     $data = DateTimeWD::getSelectDateTimeUI(new DateTimeWD($this->getCreationDate()), "network_" . $this->getId() . "_creation_date", DateTimeWD::INTERFACE_DATETIME_FIELD, "network_creation_date_input");
     $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_creation_date", $title, $data);
     // homepage_url
     $title = _("Network's web site");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_homepage_url", $this->getWebSiteURL(), "network_homepage_url_input");
     $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_homepage_url", $title, $data);
     // tech_support_email
     $title = _("Technical support email");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_tech_support_email", $this->getTechSupportEmail(), "network_tech_support_email_input");
     $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_tech_support_email", $title, $data);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_information", _("Information about the network"), implode(null, $html_network_information));
     /*
      * Network authentication
      */
     $html_network_authentication = array();
     //  network_authenticator_class
     $title = _("Network authenticator class");
     $help = _("The subclass of Authenticator to be used for user authentication. Example: AuthenticatorRadius");
     $name = "network_" . $this->getId() . "_network_authenticator_class";
     $value = htmlspecialchars($this->getAuthenticatorClassName(), ENT_QUOTES);
     $data = $this->getSelectAuthenticator($name, $value);
     $html_network_authentication[] = InterfaceElements::generateAdminSectionContainer("network_network_authenticator_class", $title, $data, $help);
     //  network_authenticator_params
     $title = _("Authenticator parameters");
     $help = _("The explicit parameters to be passed to the authenticator. You MUST read the constructor documentation of your desired authenticator class (in wifidog/classes/Authenticators/) BEFORE you start playing with this.  Example: 'my_network_id', '192.168.0.11', 1812, 1813, 'secret_key', 'CHAP_MD5'");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_network_authenticator_params", $this->getAuthenticatorConstructorParams(), "network_network_authenticator_params_input");
     $html_network_authentication[] = InterfaceElements::generateAdminSectionContainer("network_network_authenticator_params", $title, $data, $help);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_authentication", _("Network Authentication"), implode(null, $html_network_authentication));
     /*
      * Network properties
      */
     $html_network_properties = array();
     //  theme_pack
     $title = _("Selected theme pack for this network");
     $data = ThemePack::getSelectUI("network_" . $this->getId() . "_theme_pack", $this->getThemePack());
     $html_network_properties[] = InterfaceElements::generateAdminSectionContainer("network_theme_pack", $title, $data);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_properties", _("Network properties"), implode(null, $html_network_properties));
     /*
      * Network's node properties
      */
     $html_network_node_properties = array();
     //  allow_splash_only_nodes
     $title = _("Splash-only nodes");
     $help = _("Are nodes allowed to be set as splash-only (no login)?");
     $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_splash_only_nodes", "", _("Yes"), $this->getSplashOnlyNodesAllowed(), "network_allow_splash_only_nodes_radio");
     $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_splash_only_nodes", $title, $data, $help);
     //  allow_custom_portal_redirect
     $title = _("Portal page redirection");
     $help = _("Are nodes allowed to redirect users to an arbitrary web page instead of the portal?");
     $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_custom_portal_redirect", "", _("Yes"), $this->getCustomPortalRedirectAllowed(), "network_allow_custom_portal_redirect_radio");
     $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_custom_portal_redirect", $title, $data, $help);
     //  allow_original_URL_redirect
     $title = _("Original URL redirection");
     $help = _("Are nodes allowed to redirect users to the web page they originally requested instead of the portal?");
     $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_original_URL_redirect", "", _("Yes"), $this->getPortalOriginalUrlAllowed(), "network_allow_original_URL_redirect_radio");
     $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_original_URL_redirect", $title, $data, $help);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_node_properties", _("Network's node properties"), implode(null, $html_network_node_properties));
     /*
      * Network's user verification
      */
     $html_network_user_verification = array();
     //  validation_grace_time
     $title = _("Validation grace period");
     $help = _("The length of the validation grace period in seconds.  A new user is granted Internet access for this period check his email and validate his account.");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_validation_grace_time", $this->getValidationGraceTime(), "network_validation_grace_time_input");
     $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_validation_grace_time", $title, $data, $help);
     //  validation_email_from_address
     $title = _("This will be the from address of the validation email");
     $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_validation_email_from_address", $this->getValidationEmailFromAddress(), "network_validation_email_from_address_input");
     $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_validation_email_from_address", $title, $data);
     //  allow_multiple_login
     $title = _("Multiple connections");
     $help = _("Can an account be connected more than once at the same time?");
     $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_multiple_login", "", _("Yes"), $this->getMultipleLoginAllowed(), "network_allow_multiple_login_radio");
     $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_allow_multiple_login", $title, $data, $help);
     //  network_authenticator_params
     $title = _("Case sensitivity");
     $help = _("Are usernames case sensitive?");
     $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_usernames_case_sensitive", "", _("Yes"), $this->getUsernamesCaseSensitive(), "network_usernames_case_sensitive");
     $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_usernames_case_sensitive", $title, $data, $help);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_user_verification", _("Network's user verification"), implode(null, $html_network_user_verification));
     /*
      * Dynamic abuse control
      */
     $html_dynamic_abuse_control = array();
     $permArray = null;
     $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_DYNAMIC_ABUSE_CONTROL'), $this);
     if (Security::hasAnyPermission($permArray)) {
         //  connection_limit_window
         $title = _("Abuse control window");
         $help = _("The length of the window during which the user must not have exceeded the limits below.  Any valid postgresql interval expression is acceptable, typically '1 month' '1 week'.  A user who exceeds the limits will be denied access until his usage falls below the limits.");
         $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_connection_limit_window", $this->getConnectionLimitWindow(), "network_connection_limit_window_input");
         $html_dynamic_abuse_control[] = InterfaceElements::generateAdminSectionContainer("network_connection_limit_window", $title, $data, $help);
         //  connection_limit_network_max_total_bytes
         $title = _("Network max total bytes transfered");
         $help = _("Maximum data transfer during the abuse control window");
         $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_connection_limit_network_max_total_bytes", $this->getConnectionLimitNetworkMaxTotalBytes(), "network_connection_limit_network_max_total_bytes");
         $html_dynamic_abuse_control[] = InterfaceElements::generateAdminSectionContainer("network_connection_limit_network_max_total_bytes", $title, $data, $help);
         //  connection_limit_network_max_usage_duration
         $title = _("Network max connection duration");
         $help = _("Maximum connection duration during the abuse control window.  Any valid postgresql interval expression is acceptable, such as hh:mm:ss");
         $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_connection_limit_network_max_usage_duration", $this->getConnectionLimitNetworkMaxDuration(), "network_connection_limit_network_max_usage_duration");
         $html_dynamic_abuse_control[] = InterfaceElements::generateAdminSectionContainer("network_connection_limit_network_max_usage_duration", $title, $data, $help);
         //  connection_limit_node_max_total_bytes
         $title = _("Node max total bytes transfered");
         $help = _("Maximum data transfer during the abuse control window");
         $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_connection_limit_node_max_total_bytes", $this->getConnectionLimitNodeMaxTotalBytes(), "network_connection_limit_node_max_total_bytes");
         $html_dynamic_abuse_control[] = InterfaceElements::generateAdminSectionContainer("network_connection_limit_node_max_total_bytes", $title, $data, $help);
         //  connection_limit_node_max_usage_duration
         $title = _("Node max connection duration");
         $help = _("Maximum connection duration during the abuse control window.  Any valid postgresql interval expression is acceptable, such as hh:mm:ss");
         $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_connection_limit_node_max_usage_duration", $this->getConnectionLimitNodeMaxDuration(), "network_connection_limit_node_max_usage_duration");
         $html_dynamic_abuse_control[] = InterfaceElements::generateAdminSectionContainer("network_connection_limit_node_max_usage_duration", $title, $data, $help);
     } else {
         $html_dynamic_abuse_control[] = _("You do not have access to edit these options");
     }
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("network_user_verification", _("Dynamic abuse control"), implode(null, $html_dynamic_abuse_control));
     /*
      * Access management
      */
     $html_access_rights = array();
     /*
      * Access rights
      */
     if (true) {
         require_once 'classes/Stakeholder.php';
         $html_access_rights = Stakeholder::getAssignStakeholdersUI($this);
         $html .= InterfaceElements::generateAdminSectionContainer("access_rights", _("Access rights"), $html_access_rights);
     }
     /*
      * Network GIS data
      */
     if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED == true) {
         $html_network_gis_data = array();
         $gis_point = $this->getGisLocation();
         $gis_lat_name = "network_" . $this->getId() . "_gis_latitude";
         $gis_lat_value = htmlspecialchars($gis_point->getLatitude(), ENT_QUOTES);
         $gis_long_name = "network_" . $this->getId() . "_gis_longitude";
         $gis_long_value = htmlspecialchars($gis_point->getLongitude(), ENT_QUOTES);
         $gis_alt_name = "network_" . $this->getId() . "_gis_altitude";
         $gis_alt_value = htmlspecialchars($gis_point->getAltitude(), ENT_QUOTES);
         $html_network_gis_data[] = '<p>' . _("Note that to be valid, all 3 values must be present.") . "</p>\n";
         $title = _("Latitude");
         $help = _("Center latitude for the area covered by your wireless network");
         $data = InterfaceElements::generateInputText($gis_lat_name, $gis_lat_value, "network_gis_latitude_input");
         $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_latitude", $title, $data, $help);
         $title = _("Longitude");
         $help = _("Center longitude for the area covered by your wireless network");
         $data = InterfaceElements::generateInputText($gis_long_name, $gis_long_value, "network_gis_longitude_input");
         $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_longitude", $title, $data, $help);
         $title = _("Zoomlevel");
         $help = _("Zoomlevel of the Google Map.  12 is a typical value.");
         $data = InterfaceElements::generateInputText($gis_alt_name, $gis_alt_value, "network_gis_altitude_input");
         $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_altitude", $title, $data, $help);
         $title = _("Map type");
         $help = _("Default Google Map type for your the area of your wireless network");
         $data = $this->getSelectGisMapType("network_" . $this->getId() . "_gmaps_map_type", $this->getGisMapType());
         $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gmaps_map_type", $title, $data, $help);
         // Build section
         $html .= InterfaceElements::generateAdminSectionContainer("network_gis_data", _("GIS data"), implode(null, $html_network_gis_data));
     }
     // Profile templates
     $title = _("Network profile templates");
     $name = "network_" . $this->_id . "_profile_templates";
     $data = ProfileTemplate::getLinkedProfileTemplateUI($name, "network_has_profile_templates", "network_id", $this->_id);
     $html .= InterfaceElements::generateAdminSectionContainer("network_profile_templates", $title, $data);
     // objects hierarchy
     $html .= parent::getGraphAdminUI($this);
     $html .= "</ul>\n";
     $html .= "</fieldset>";
     return $html;
 }
 /**
  * Retreives the admin interface of this object
  * 
  * @param Network $network the network of this element
  *
  * @return string The HTML fragment for this interface
  */
 public function getGraphAdminUI($network = null)
 {
     $html = '';
     /** Until phase 2 of node group and hotspot graph, when this is called, it means the permissions have already been verified on the child element */
     require_once 'classes/InterfaceElements.php';
     require_once 'classes/Stakeholder.php';
     // Group section
     if (is_null($network) || Security::hasPermission(Permission::P('NETWORK_PERM_ALLOW_GROUP_NODE'), $network)) {
         $hge_id = $this->getHgeId();
         $_html_content = array();
         $_title = _("Hierarchy");
         $_data = HotspotGraph::getGraphAdminUI("hge_" . $hge_id . "_graph", $this);
         $html .= InterfaceElements::generateAdminSectionContainer("hge_graph", $_title, $_data);
     }
     return $html;
 }
Esempio n. 9
0
 function execute($par)
 {
     global $wgOut, $wgRequest, $wgUser, $wgParser, $wgDebugToolbar;
     $user = $this->getUser();
     wfLoadExtensionMessages("TipsPatrol");
     if ($user->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     if ($user->isAnon() || self::isBlockedFromTipsPatrol($user)) {
         $wgOut->setRobotpolicy('noindex,nofollow');
         $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext');
         return;
     }
     $this->skipTool = new ToolSkip("tiptool", "tipsandwarnings", "tw_checkout", "tw_checkout_user", "tw_id");
     if ($wgRequest->wasPosted()) {
         $wgOut->disable();
         $result = array();
         try {
             $tipId = $wgRequest->getVal('tipId');
             if ($wgRequest->getVal('coachTip')) {
                 $tip = $wgRequest->getVal('tip');
                 $this->coachResult($tipId, $tip, &$result);
             } elseif ($tipId != null && $wgRequest->getVal('skipTip')) {
                 $this->logTip($tipId, self::TIP_ACTION_SKIP);
                 $this->skipTool->skipItem($tipId);
                 $this->skipTool->unUseItem($tipId);
             } elseif ($wgRequest->getVal('deleteTip')) {
                 $tip = $wgRequest->getVal('tip');
                 $this->logTip($tipId, self::TIP_ACTION_DELETE, $tip);
                 $articleId = $wgRequest->getVal('articleId');
                 $this->deleteTip($tipId, $articleId, $tip);
             } elseif ($wgRequest->getVal('keepTip')) {
                 $articleId = $wgRequest->getVal('articleId');
                 $tip = $wgRequest->getVal('tip');
                 $qcId = $this->addToQG($tipId, $articleId, $tip);
                 $this->logTip($tipId, self::TIP_ACTION_KEEP, $tip, $qcId);
                 $dbw = wfGetDB(DB_MASTER);
                 $dbw->delete('tipsandwarnings', array('tw_id' => $tipId));
             }
             $this->getNextTip(&$result);
             // if debug toolbark pass logs back in response
             if ($wgDebugToolbar) {
                 $result['debug']['log'] = MWDebug::getLog();
             }
             echo json_encode($result);
         } catch (MWException $e) {
             $result['error'][] = $e->getText();
             echo json_encode($result);
             throw $e;
         }
         return;
     }
     $wgOut->setHTMLTitle(wfMessage('tipspatrol')->text());
     $wgOut->setPageTitle(wfMessage('tipspatrol')->text());
     $wgOut->addJSCode('mt');
     // Mousetrap library
     $wgOut->addCSSCode('tpc');
     // Tips Patrol CSS
     $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('tipspatrol.js'), 'extensions/wikihow/tipsandwarnings'));
     if ($wgDebugToolbar) {
         $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('consoledebug.js'), 'extensions/wikihow/debug', false));
     }
     EasyTemplate::set_path(dirname(__FILE__));
     $vars = array();
     $vars['tip_skip_title'] = wfMessage('tip_skip_title')->text();
     $vars['tip_keep_title'] = wfMessage('tip_keep_title')->text();
     $vars['tip_delete_title'] = wfMessage('tip_delete_title')->text();
     $wgOut->addHTML(EasyTemplate::html('TipsPatrol.tmpl.php', $vars));
     $coach = $this->getRequest()->getVal("coach");
     // code to init the tipspatrol javascript.. doing it here lets us pass in extra variables when we init
     $wgOut->addScript("<script>\$(document).ready(function(){WH.tipsPatrol.init({$coach})});</script>");
     $bubbleText = "Only publish this tip if you can make it helpful, clear, and grammatically correct. Most tips should get deleted.";
     InterfaceElements::addBubbleTipToElement('tip_tip', 'tptrl', $bubbleText);
     $this->displayLeaderboards();
 }
Esempio n. 10
0
 public function getAdminUI()
 {
     $db = AbstractDb::getObject();
     $currentUser = self::getCurrentUser();
     $userPreferencesItems = array();
     $finalHtml = '';
     if (Security::hasPermission(Permission::P('NETWORK_PERM_VIEW_STATISTICS'), $this->getNetwork())) {
         /* Statistics */
         $content = "<a href='" . BASE_SSL_PATH . "admin/stats.php?Statistics=" . $this->getNetwork()->getId() . "&distinguish_users_by=user_id&stats_selected_users=" . $this->getUsername() . "&UserReport=on&user_id=" . $this->getId() . "&action=generate'>" . _("Get user statistics") . "</a>\n";
         $administrationItems[] = InterfaceElements::genSectionItem($content);
         /* Account status */
         $title = _("Account Status");
         $help = _("Note that Error is for internal use only");
         $name = "user_" . $this->getId() . "_accountstatus";
         global $account_status_to_text;
         $content = FormSelectGenerator::generateFromKeyLabelArray($account_status_to_text, $this->getAccountStatus(), $name, null, false);
         $administrationItems[] = InterfaceElements::genSectionItem($content, $title, $help);
         $finalHtml .= InterfaceElements::genSection($administrationItems, _("Administrative options"));
     }
     if ($this == $currentUser && !$this->isSplashOnlyUser() || Security::hasPermission(Permission::P('NETWORK_PERM_EDIT_ANY_USER'), $this->getNetwork())) {
         /* Username */
         $title = _("Username");
         $name = "user_" . $this->getId() . "_username";
         $content = "<input type='text' name='{$name}' value='" . htmlentities($this->getUsername()) . "' size=30><br/>\n";
         $content .= _("Be careful when changing this: it's the username you use to log in!");
         $userPreferencesItems[] = InterfaceElements::genSectionItem($content, $title);
         /* Email */
         $title = _("Email");
         $name = "email_" . $this->getId() . "_email";
         $content = "<input type='text' name='{$name}' disabled='disabled' value='" . htmlentities($this->getEmail()) . "' size=30><br/>\n";
         $content .= _("If you wish to change this address, please Email Support!");
         $userPreferencesItems[] = InterfaceElements::genSectionItem($content, $title);
         /* Change password */
         $changePasswordItems = array();
         if ($this == $currentUser) {
             //Don't enter the old password if changing password for another user
             $title = _("Your current password");
             $name = "user_" . $this->getId() . "_oldpassword";
             $content = "<input type='password' name='{$name}' size='20'>\n";
             $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title);
         }
         $title = _("Your new password");
         $name = "user_" . $this->getId() . "_newpassword";
         $content = "<input type='password' name='{$name}' size='20'>\n";
         $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title);
         $title = _("Your new password (again)");
         $name = "user_" . $this->getId() . "_newpassword_again";
         $content = "<input type='password' name='{$name}' size='20'>\n";
         $changePasswordItems[] = InterfaceElements::genSectionItem($content, $title);
         $userPreferencesItems[] = InterfaceElements::genSection($changePasswordItems, _("Change my password"));
         $finalHtml .= InterfaceElements::genSection($userPreferencesItems, _("User preferences"), false, false, get_class($this));
         //N.B: For now, let pretend we have only one profile per use...
         $profiles = $this->getAllProfiles();
         $current_profile = null;
         if (!empty($profiles)) {
             $current_profile = $profiles[0];
         }
         if ($current_profile != null) {
             $finalHtml .= $current_profile->getAdminUI();
             $name = "user_" . $this->getId() . "_delete_profile_" . $current_profile->getId();
             $value = _("Completely delete my public profile");
             $finalHtml .= "<div class='admin_element_tools'>";
             $finalHtml .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">';
             $finalHtml .= "</div>";
         } else {
             // Get the list of profile templates for the users' network
             $profile_templates = ProfileTemplate::getAllProfileTemplates($this->getNetwork());
             if (!empty($profile_templates)) {
                 $name = "user_" . $this->getId() . "_add_profile";
                 $value = _("Create my public profile");
                 $finalHtml .= "<div class='admin_element_tools'>";
                 $finalHtml .= '<input type="submit" class="submit" name="' . $name . '" value="' . $value . '">';
                 $finalHtml .= "</div>";
             }
         }
     }
     return $finalHtml;
 }
Esempio n. 11
0
 /**
  * Retreives the admin interface of this object
  *
  * @return string The HTML fragment for this interface
  */
 public function getAdminUI()
 {
     Security::requirePermission(Permission::P('SERVER_PERM_EDIT_SERVER_CONFIG'), $this);
     // Init values
     $db = AbstractDb::getObject();
     $html = '';
     $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n";
     $html .= "<legend>" . _("Server management") . "</legend>\n";
     $html .= "<ul class='admin_element_list'>\n";
     // server_id
     /*$value = htmlspecialchars($this->getId(), ENT_QUOTES);
     
             $html .= "<li class='admin_element_item_container'>\n";
             $html .= "<div class='admin_element_label'>" . _("Server ID") . ":</div>\n";
             $html .= "<div class='admin_element_data'>\n";
             $html .= $value;
             $html .= "</div>\n";
             $html .= "</li>\n";*/
     // creation_date
     $name = "server_" . $this->getId() . "_creation_date";
     $value = htmlspecialchars($this->getCreationDate(), ENT_QUOTES);
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("Creation date") . ":</div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $html .= $value . "\n";
     $html .= "</div>\n";
     $html .= "</li>\n";
     //timezone check
     $html .= "<li class='admin_element_item_container'>\n";
     $html .= "<div class='admin_element_label'>" . _("Timezone check:  The following must be in the same timezone") . ":</div>\n";
     $html .= "<div class='admin_element_data'>\n";
     $html .= "<p>";
     $db->execSqlUniqueRes("SHOW timezone", $row, false);
     $html .= " " . sprintf(_("Timezone from postgresql: %s"), $row['TimeZone']) . "</p>";
     // Version < 5.0.0
     $date_default_timezone_get = 'date_default_timezone_get';
     is_callable($date_default_timezone_get) ? $phpTimezone = date_default_timezone_get() : ($phpTimezone = "Requires PHP 5.1 to tell");
     $html .= " " . sprintf(_("Timezone from PHP: %s"), $phpTimezone) . "</p>";
     // Version < 5.0.0
     $html .= "</div>\n";
     $html .= "</li>\n";
     /*
      * Authentication options
      */
     $title = _("Authentication");
     $data = InterfaceElements::generateInputCheckbox("use_global_auth", "", _("Use the users of default Virtual Host's network across all networks on the server."), $this->getUseGlobalUserAccounts(), "use_global_auth");
     $html .= InterfaceElements::generateAdminSectionContainer("server_authentication_options", $title, $data);
     /*
      * Access rights
      */
     if (true) {
         require_once 'classes/Stakeholder.php';
         $html_access_rights = Stakeholder::getAssignStakeholdersUI($this);
         $html .= InterfaceElements::generateAdminSectionContainer("access_rights", _("Access rights"), $html_access_rights);
     }
     $html .= "</ul>\n";
     $html .= "</fieldset>\n";
     return $html;
 }
Esempio n. 12
0
 /**
  * Get a flexible interface to view the children and parents of a given element
  * One can add parents and children to the hierarchy 
  *
  * @param string $user_prefix            A identifier provided by the
  *                                       programmer to recognise it's
  *                                       generated HTML form
  * @param string $graph_element          Hotspot_Graph_Element
  * @return string HTML markup
  */
 public static function getGraphAdminUI($user_prefix, $graph_element)
 {
     $db = AbstractDb::getObject();
     // Init values
     $html = "";
     $object_id = $db->escapeString($graph_element->getHgeId());
     // Get the parents
     if (!$graph_element->isRoot()) {
         $_title = _("Parents :");
         $parent_rows = HotspotGraph::getParents($object_id);
         $listData = "";
         if ($parent_rows) {
             foreach ($parent_rows as $parent_row) {
                 $classname = $parent_row['element_type'];
                 $element = HotspotGraphElement::getObject($parent_row['element_id'], $classname);
                 $parentStr = htmlspecialchars($parent_row['name']) . " (" . htmlspecialchars($parent_row['element_type']) . ")  ";
                 $name = $object_id . "_parent_" . $parent_row['next_element_id'] . "_remove";
                 $listDataContents = InterfaceElements::generateAdminSection("", $parentStr, InterfaceElements::generateInputSubmit($name, _("Remove from")));
                 $listData .= "<li class='admin_element_item_container node_owner_list'>" . $listDataContents . "</li>\n";
             }
         }
         $listData .= "<li class='admin_element_item_container'>";
         $listData .= HotspotGraphElement::getSelectGraphElementUI($object_id . "_parent_add_element", array('additionalWhere' => " AND element_type in ('Network', 'NodeGroup') AND hotspot_graph_element_id != '{$db->escapeString($graph_element->getHgeId())}'"));
         $listData .= InterfaceElements::generateInputSubmit($object_id . "_parent_add", _("Add"));
         $listData .= "<br class='clearbr' /></li>\n";
         $_data = "<ul id='node_owner_ul' class='admin_element_list'>\n" . $listData . "</ul>\n";
         $html .= InterfaceElements::generateAdminSectionContainer("element_parent", $_title, $_data);
     }
     // Get the children
     if (!$graph_element->isLeaf()) {
         $_title = _("Children :");
         $children_rows = HotspotGraph::getChildren($object_id);
         $listData = "";
         if ($children_rows) {
             foreach ($children_rows as $child_row) {
                 $classname = $child_row['element_type'];
                 $element = HotspotGraphElement::getObject($child_row['element_id'], $classname);
                 $childStr = htmlspecialchars($child_row['name']) . " (" . htmlspecialchars($child_row['element_type']) . ")  ";
                 $name = $object_id . "_child_" . $child_row['next_element_id'] . "_remove";
                 $listDataContents = InterfaceElements::generateAdminSection("", $childStr, InterfaceElements::generateInputSubmit($name, _("Remove from")));
                 $listData .= "<li class='admin_element_item_container node_owner_list'>" . $listDataContents . "</li>\n";
             }
         }
         $listData .= "<li class='admin_element_item_container'>";
         $listData .= HotspotGraphElement::getSelectGraphElementUI($object_id . "_child_add_element", array('additionalWhere' => " AND element_type in ('Node', 'NodeGroup') AND hotspot_graph_element_id != '{$db->escapeString($graph_element->getHgeId())}'"));
         $listData .= InterfaceElements::generateInputSubmit($object_id . "_child_add", _("Add"));
         $listData .= "<br class='clearbr' /></li>\n";
         $_data = "<ul id='node_owner_ul' class='admin_element_list'>\n" . $listData . "</ul>\n";
         $html .= InterfaceElements::generateAdminSectionContainer("element_children", $_title, $_data);
     }
     return $html;
 }
Esempio n. 13
0
 /**
  * Retrieves the admin interface of this object
  *
  * @return string The HTML fragment for this interface
  *
  * @access public
  *
  * @todo Most of this code will be moved to Hotspot class when the
  *       abtraction will be completed
  */
 public function getAdminUI()
 {
     $permArray = null;
     $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $this->getNetwork());
     $permArray[] = array(Permission::P('NODE_PERM_EDIT_CONFIG'), $this);
     $permArray[] = array(Permission::P('NODE_PERM_EDIT_GATEWAY_ID'), $this);
     $permArray[] = array(Permission::P('NODE_PERM_EDIT_DEPLOYMENT_DATE'), $this);
     Security::requireAnyPermission($permArray);
     require_once 'classes/InterfaceElements.php';
     require_once 'classes/Stakeholder.php';
     // Init values
     $html = '';
     // Get information about the network
     $network = $this->getNetwork();
     $node_id = $this->getId();
     /*
      * Check for a warning message
      */
     if ($this->_warningMessage != "") {
         $html .= "<div class='errormsg'>" . $this->_warningMessage . "</div>\n";
     }
     /*
      * Begin with admin interface
      */
     $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n";
     $html .= "<legend>" . _("Edit a node") . "</legend>\n";
     $html .= "<ul class='admin_element_list'>\n";
     /*
      * Display stats
      */
     $permArray = null;
     $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $network);
     $permArray[] = array(Permission::P('NODE_PERM_ALLOW_GENERATING_PUBLIC_STATS'), $this);
     if (Security::hasAnyPermission($permArray)) {
         $_title = _("Statistics");
         $_data = InterfaceElements::generateInputCheckbox("allows_public_stats", "", _("Allow public access to some node statistics."), $this->getAllowsPublicStats(), "allows_public_stats");
         $_data .= InterfaceElements::generateInputSubmit("node_" . $this->id . "_get_stats", _("Get access statistics"), "node_get_stats_submit");
         $html .= InterfaceElements::generateAdminSectionContainer("node_get_stats", $_title, $_data);
     }
     /*
      * Information about the node
      */
     $_html_node_information = array();
     // Gateway ID
     $_title = _("Gateway ID");
     $permArray = null;
     $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $network);
     $permArray[] = array(Permission::P('NODE_PERM_EDIT_GATEWAY_ID'), $this);
     if (Security::hasAnyPermission($permArray)) {
         $_data = InterfaceElements::generateInputText("node_" . $node_id . "_gw_id", $this->getGatewayId(), "gw_id_input");
     } else {
         $_data = htmlspecialchars($this->getGatewayId(), ENT_QUOTES);
         $_data .= InterfaceElements::generateInputHidden("node_" . $node_id . "_gw_id", $this->getGatewayId());
     }
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("gateway_id", $_title, $_data);
     //Node content
     $html .= parent::getContentAdminUI();
     // Name
     $permArray = null;
     $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $network);
     $permArray[] = array(Permission::P('NODE_PERM_EDIT_NAME'), $this);
     if (Security::hasAnyPermission($permArray)) {
         $_title = _("Name");
         $_data = InterfaceElements::generateInputText("node_" . $node_id . "_name", $this->getName(), "node_name_input");
         $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_name", $_title, $_data);
     } else {
         $_title = _("Name");
         $_data = $this->getName();
         $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_name", $_title, $_data);
     }
     // Creation date
     $_title = _("Creation date");
     $permArray = null;
     $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $network);
     $permArray[] = array(Permission::P('NODE_PERM_EDIT_DEPLOYMENT_DATE'), $this);
     if (Security::hasAnyPermission($permArray)) {
         $_data = DateTimeWD::getSelectDateTimeUI(new DateTimeWD($this->getCreationDate()), "node_" . $node_id . "_creation_date", DateTimeWD::INTERFACE_DATETIME_FIELD, "node_creation_date_input");
     } else {
         $_data = htmlspecialchars($this->getCreationDate(), ENT_QUOTES);
         $_data .= InterfaceElements::generateInputHidden("node_" . $node_id . "_creation_date", $this->getCreationDate());
     }
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_creation_date", $_title, $_data);
     // Description
     $_title = _("Description");
     $name = "node_" . $node_id . "_description";
     $_data = "<textarea name='{$name}' cols=80 rows=5 id='node_description_textarea'>\n" . $this->getDescription() . "\n</textarea>\n";
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_description", $_title, $_data);
     // Civic number
     $_title = _("Civic number");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_civic_number", $this->getCivicNumber(), "node_civic_number_input");
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_civic_number", $_title, $_data);
     // Street name
     $_title = _("Street name");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_street_name", $this->getStreetName(), "node_street_name_input");
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_street_name", $_title, $_data);
     // City
     $_title = _("City");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_city", $this->getCity(), "node_city_input");
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_city", $_title, $_data);
     // Province
     $_title = _("Province / State");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_province", $this->getProvince(), "node_province_input");
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_province", $_title, $_data);
     // Postal Code
     $_title = _("Postal code");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_postal_code", $this->getPostalCode(), "node_postal_code_input");
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_postal_code", $_title, $_data);
     // Country
     $_title = _("Country");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_country", $this->getCountry(), "node_country_input");
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_country", $_title, $_data);
     // Public phone #
     $_title = _("Public phone number");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_public_phone", $this->getTelephone(), "node_public_phone_input");
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_public_phone", $_title, $_data);
     // Public mail
     $_title = _("Public email");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_public_email", $this->getEmail(), "node_public_email_input");
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_public_email", $_title, $_data);
     // Homepage URL
     $_title = _("Homepage URL");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_homepage_url", $this->getWebSiteURL(), "node_homepage_url_input");
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_homepage_url", $_title, $_data);
     // Mass transit info
     $_title = _("Mass transit info");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_mass_transit_info", $this->getTransitInfo(), "node_mass_transit_info_input");
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_mass_transit_info", $_title, $_data);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("node_information", _("Information about the node"), implode(null, $_html_node_information));
     /*
      * Node GIS data
      */
     $_html_node_gis_data = array();
     $gis_point = $this->getGisLocation();
     // Latitude
     $_title = _("Latitude");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_gis_latitude", $gis_point->getLatitude(), "node_" . $node_id . "_gis_latitude");
     $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_gis_latitude", $_title, $_data);
     // Latitude
     $_title = _("Longitude");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_gis_longitude", $gis_point->getLongitude(), "node_" . $node_id . "_gis_longitude");
     $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_gis_longitude", $_title, $_data);
     // Call the geocoding service, if Google Maps is enabled then use Google Maps to let the user choose a more precise location
     if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED === true) {
         $_data = InterfaceElements::generateInputSubmit("geocode_only", _("Geocode the address or postal code above"), "geocode_only_submit");
         $_data .= InterfaceElements::generateInputButton("google_maps_geocode", _("Check using Google Maps"), "google_maps_geocode_button", "submit", array("onclick" => "window.open('hotspot_location_map.php?node_id={$this->getId()}', 'hotspot_location', 'toolbar = 0, scrollbars = 1, resizable = 1, location = 0, statusbar = 0, menubar = 0, width = 600, height = 600');"));
         $_data .= "<div class='admin_section_hint' id='node_gis_geocode_hint'>" . "(" . _("Use a geocoding service, then use Google Maps to pinpoint the exact location.") . ")" . "</div>\n";
     } else {
         $_data = InterfaceElements::generateInputSubmit("geocode_only", _("Geocode the address or postal code above"), "geocode_only_submit");
         $_data .= "<div class='admin_section_hint' id='node_gis_geocode_hint'>" . "(" . _("Use a geocoding service") . ")" . "</div>\n";
     }
     $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_gis_geocode", "", $_data);
     // Map URL
     $_title = _("Map URL");
     $_data = InterfaceElements::generateInputText("node_" . $node_id . "_map_url", $this->getMapURL(), "node_map_url_input");
     $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_map_url", $_title, $_data);
     $_title = _("Show node on map");
     $help = _("Should this node be visible on the map when deployed?");
     $_data = InterfaceElements::generateInputCheckbox("node_" . $node_id . "_show_on_map", "", _("Yes"), $this->showOnMap(), "node_show_on_map_input");
     $_html_node_gis_data[] = InterfaceElements::generateAdminSectionContainer("node_show_on_map", $_title, $_data, $help);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("node_gis_data", _("GIS data"), implode(null, $_html_node_gis_data));
     /*
      * Node configuration section
      */
     $_html_node_config = array();
     // Deployment status
     $_title = _("Node deployment status");
     $_data = $this->getSelectDeploymentStatus("node_" . $node_id . "_deployment_status");
     $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_deployment_status", $_title, $_data);
     // Network selection
     $_title = _("Node Network");
     $_data = Network::getSelectUI("node_" . $node_id . "_network_id", array('preSelectedObject' => $this->getNetwork()));
     $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_network", $_title, $_data);
     //  is_splash_only_node
     if ($network->getSplashOnlyNodesAllowed()) {
         $_title = _("Is this node splash-only (no login)?");
         $_data = InterfaceElements::generateInputCheckbox("node_" . $node_id . "_is_splash_only_node", "", _("Yes"), $this->isConfiguredSplashOnly(), "node_is_splash_only_node_radio");
         $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_is_splash_only_node", $_title, $_data);
     }
     // custom_portal_redirect_url
     if ($network->getCustomPortalRedirectAllowed()) {
         $_title = _("URL to show instead of the portal");
         $_data = InterfaceElements::generateInputText("node_" . $node_id . "_custom_portal_redirect_url", $this->getCustomPortalRedirectUrl(), "node_custom_portal_redirect_url_input");
         $_data .= _("If this is not empty, the portal will be disabled and this URL will be shown instead");
         $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_custom_portal_redirect_url", $_title, $_data);
     }
     //  allow_original_URL_redirect
     $title = _("Original URL redirection");
     $help = _("Are nodes allowed to redirect users to the web page they originally requested instead of the portal? this will overide the custom portal URL");
     $data = InterfaceElements::generateInputCheckbox("node_" . $node_id . "_allow_original_URL_redirect", "", _("Yes"), $this->getPortalOriginalUrlAllowed(), "node_allow_original_URL_redirect_radio");
     $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_allow_original_URL_redirect", $title, $data, $help);
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("node_config", _("Node configuration"), implode(null, $_html_node_config));
     /*
      * Access rights
      */
     if (User::getCurrentUser()->DEPRECATEDisSuperAdmin()) {
         require_once 'classes/Stakeholder.php';
         $html_access_rights = Stakeholder::getAssignStakeholdersUI($this);
         $html .= InterfaceElements::generateAdminSectionContainer("access_rights", _("Access rights"), $html_access_rights);
     }
     //Node hierarchy
     $html .= parent::getGraphAdminUI($network);
     $html .= "</ul>\n";
     $html .= "</fieldset>";
     return $html;
 }
Esempio n. 14
0
 function execute($par)
 {
     global $wgDebugToolbar;
     $request = $this->getRequest();
     $out = $this->getOutput();
     $this->checkPermissions();
     wfLoadExtensionMessages("UCIPatrol");
     if ($request->getVal("stats")) {
         $out->disable();
         $result = $this->getStats();
         if ($request->getVal("format") == "json") {
             echo json_encode($result);
             return;
         }
         UCIPatrol::printStatsUploads($result['uploads']);
         UCIPatrol::printStatsTitles($result['titles']);
         return;
     }
     if ($request->wasPosted()) {
         $out->disable();
         // wrapping it all in try catch to get any database errors
         try {
             $result = array();
             if ($request->getVal('next')) {
                 $result = $this->getNext();
             } elseif ($request->getVal('skip')) {
                 $this->skip();
             } elseif ($request->getVal('bad')) {
                 $this->downVote();
             } elseif ($request->getVal('good')) {
                 $this->upVote();
             } elseif ($request->getVal('undo')) {
                 $this->undo();
             } elseif ($request->getVal('error')) {
                 $this->error();
                 $result = $this->getNext();
             } elseif ($request->getVal('resetskip')) {
                 $this->resetSkip();
                 $result = $this->getNext();
             } elseif ($request->getVal('flag')) {
                 $this->flag();
                 $result = UCIPatrol::getImagesHTML($request->getVal('hostPage'));
                 echo $result;
                 return;
             }
             // if debug toolbar is active, pass logs back in json response
             if ($wgDebugToolbar) {
                 $result['debug']['log'] = MWDebug::getLog();
             }
             echo json_encode($result);
         } catch (MWException $e) {
             $result = $result ?: array();
             $result['error'][] = $e->getText();
             echo json_encode($result);
             throw $e;
         }
     } else {
         $out->setHTMLTitle(wfMessage('ucipatrol')->text());
         $out->setPageTitle(wfMessage('ucipatrol')->text());
         $out->addJSCode('mt');
         // Mousetrap library
         $out->addCSSCode('ucipc');
         // Tips Patrol CSS
         $out->addScript(HtmlSnips::makeUrlTags('js', array('ucipatrol.js'), 'extensions/wikihow/mobile/ucipatrol', false));
         if ($wgDebugToolbar) {
             $out->addScript(HtmlSnips::makeUrlTags('js', array('consoledebug.js'), 'extensions/wikihow/debug', false));
         }
         EasyTemplate::set_path(dirname(__FILE__));
         $anon = $this->getUser()->isAnon();
         $out->addHTML(EasyTemplate::html('UCIPatrol.tmpl.php', $vars));
         $out->addScript("<script>\$(document).ready(function(){WH.uciPatrol.init({$anon})});</script>");
         $bubbleText = "Help us pick the best user submitted photos to match the article.";
         InterfaceElements::addBubbleTipToElement('uci', 'ucitp', $bubbleText);
         $this->displayLeaderboards();
     }
 }
Esempio n. 15
0
 /**
  * Retrieves the admin interface of this object
  *
  * @return string The HTML fragment for this interface
  *
  * @access public
  *
  * @todo Most of this code will be moved to Hotspot class when the
  *       abtraction will be completed
  */
 public function getAdminUI()
 {
     $permArray = null;
     /** @todo this should not be the default network here */
     $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODEGROUP_CONFIG'), Network::getDefaultNetwork());
     $permArray[] = array(Permission::P('NODEGROUP_PERM_EDIT_ANY_NODEGROUP_CONFIG'), $this);
     $permArray[] = array(Permission::P('NODEGROUP_PERM_EDIT_NODEGROUP_CONFIG'), $this);
     Security::requireAnyPermission($permArray);
     require_once 'classes/InterfaceElements.php';
     require_once 'classes/Stakeholder.php';
     // Init values
     $html = '';
     $ng_id = $this->getId();
     /*
      * Check for a warning message
      */
     if ($this->_warningMessage != "") {
         $html .= "<div class='errormsg'>" . $this->_warningMessage . "</div>\n";
     }
     /*
      * Begin with admin interface
      */
     $html .= "<fieldset class='admin_container " . get_class($this) . "'>\n";
     $html .= "<legend>" . _("Edit a node group") . "</legend>\n";
     $html .= "<ul class='admin_element_list'>\n";
     /*
      * Information about the node group
      */
     $_html_node_information = array();
     // Name
     $permArray = null;
     $permArray[] = array(Permission::P('NETWORK_PERM_EDIT_ANY_NODEGROUP_CONFIG'), Network::getDefaultNetwork());
     $permArray[] = array(Permission::P('NODEGROUP_PERM_EDIT_NODEGROUP_CONFIG'), $this);
     if (Security::hasAnyPermission($permArray)) {
         $_title = _("Name");
         $_data = InterfaceElements::generateInputText("node_group_" . $ng_id . "_name", $this->getName(), "node_group_name_input");
         $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_group_name", $_title, $_data);
     } else {
         $_title = _("Name");
         $_data = $this->getName();
         $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_group_name", $_title, $_data);
     }
     // Description
     $_title = _("Description");
     $name = "node_" . $ng_id . "_description";
     $_data = "<textarea name='{$name}' cols=80 rows=5 id='node_description_textarea'>\n" . $this->getDescription() . "\n</textarea>\n";
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_description", $_title, $_data);
     // Creation date
     $_title = _("Creation date");
     $_data = DateTimeWD::getSelectDateTimeUI(new DateTimeWD($this->getCreationDate()), "node_group_" . $ng_id . "_creation_date", DateTimeWD::INTERFACE_DATETIME_FIELD, "node_group_creation_date_input");
     $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_creation_date", $_title, $_data);
     //Node content
     $html .= parent::getContentAdminUI();
     //Node hierarchy
     $html .= parent::getGraphAdminUI();
     // Build section
     $html .= InterfaceElements::generateAdminSectionContainer("node_group_information", _("Information about the node group"), implode(null, $_html_node_information));
     /*
      * Access rights
      */
     if (User::getCurrentUser()->DEPRECATEDisSuperAdmin()) {
         require_once 'classes/Stakeholder.php';
         $html_access_rights = Stakeholder::getAssignStakeholdersUI($this);
         $html .= InterfaceElements::generateAdminSectionContainer("access_rights", _("Access rights"), $html_access_rights);
     }
     $html .= "</ul>\n";
     $html .= "</fieldset>";
     return $html;
 }
Esempio n. 16
0
 /**
  * Retreives the admin interface of this object
  *
  * @return string The HTML fragment for this interface
  */
 public function getAdminUI()
 {
     // Init values
     $html = '';
     // All sections
     $profileSections = array();
     // Metadata section
     $profileMetadataItems = array();
     //  is_visible
     $title = _("Should this profile be publicly visible?");
     $name = "profile_" . $this->getId() . "_is_visible";
     $data = InterfaceElements::generateInputCheckbox($name, "", _("Yes"), $this->isVisible(), "profile_is_visible_radio");
     $profileMetadataItems[] = InterfaceElements::genSectionItem($data, $title);
     $profileSections[] = InterfaceElements::genSection($profileMetadataItems, _("Profile preferences"));
     // Fields section
     $profileFieldsUI = array();
     $template = $this->getTemplate();
     // Aggregate the fields UI
     $profileFields = $this->getFields();
     //var_dump($profileFields);
     foreach ($template->getFields() as $templateField) {
         //var_dump($templateField);
         if (!empty($profileFields[$templateField->getId()])) {
             //We already have a real field instanciated
             $field = $profileFields[$templateField->getId()];
             //var_dump($field);
             $profileFieldsUI[] = InterfaceElements::genSectionItem($field->getAdminUI());
         } else {
             //show the template admin UI
             //$profileFieldsUI[] = InterfaceElements::genSectionItem($templateField->getUserUI());
             // Init values
             $tmp_html = '';
             $admin_label = $templateField->getAdminLabelContent();
             if ($admin_label != null) {
                 $title = $admin_label->__toString();
             } else {
                 $title = null;
             }
             $tmp_html .= "<fieldset class='admin_container " . get_class($this) . "'>\n";
             if (!empty($title)) {
                 $tmp_html .= "<legend>{$title}</legend>\n";
             }
             $futureProfileFieldId = get_guid();
             $name = "profile_template_field_{$templateField->getId()}_field_future_id";
             $tmp_html .= '<input type="hidden" name="' . $name . '" value="' . $futureProfileFieldId . '">';
             $userData['contentTypeFilter'] = $templateField->getContentTypeFilter();
             //echo "Profile::getAdminUI: userData";pretty_print_r($userData);
             $tmp_html .= ProfileField::getNewUI($futureProfileFieldId, $userData);
             $tmp_html .= "</fieldset>\n";
             $profileFieldsUI[] = $tmp_html;
         }
     }
     $profileSections[] = InterfaceElements::genSection($profileFieldsUI, _("Profile fields"));
     $html .= InterfaceElements::genSection($profileSections, _("Profile"), false, false, get_class($this));
     return $html;
 }