function manageEditors()
 {
     if ($_SESSION["OBJ_user"]->allow_access("xwysiwyg", "settings")) {
         $this->content .= "<a href=\"" . $this->linkRef . "&amp;action=admin" . "\">" . $_SESSION['translate']->it("Back to administration") . "</a>";
         if (isset($_GET['updList'])) {
             //to update, simply delete the existing file
             @unlink(PHPWS_HOME_DIR . "files/xwysiwyg/editors/list.txt");
         }
         $editors = array();
         $formTags = array();
         $table = array();
         $this->content .= "<br /><br /><b>" . $_SESSION['translate']->it("Available editors") . "</b>";
         $table[] = array("<b>" . $_SESSION['translate']->it("Location") . "</b>", "<b>" . $_SESSION['translate']->it("Editor") . "</b>", "<b>" . $_SESSION['translate']->it("Status") . "</b>", "<b>" . $_SESSION['translate']->it("Action") . "</b>");
         $dir = PHPWS_File::readDirectory(PHPWS_HOME_DIR . "files/xwysiwyg/editors/", FALSE, TRUE, FALSE, array('conf'));
         if (is_array($dir)) {
             $location = $_SESSION['translate']->it("local");
             foreach ($dir as $file) {
                 include PHPWS_HOME_DIR . "files/xwysiwyg/editors/" . $file;
                 $editors[] = $cfg_editor;
                 $result = $GLOBALS['core']->quickFetch("SELECT editor FROM mod_xw_config WHERE editor = '{$cfg_editor}'", TRUE, TRUE);
                 if ($result) {
                     $status = $_SESSION['translate']->it("installed");
                     $action_link = $this->linkRef . "&amp;action=delEditor&amp;delEditor={$cfg_editor}";
                     $action_label = $_SESSION['translate']->it("Uninstall");
                     $action = "<a href=\"{$action_link}\">{$action_label}</a>";
                     $select = $GLOBALS['core']->quickFetch("SELECT editor FROM mod_xw_editor", TRUE, TRUE);
                     if ($select['editor'] == $cfg_editor) {
                         $editor = "<strong>{$cfg_editor}</strong>";
                     } else {
                         $action_link = $this->linkRef . "&amp;action=toggle&amp;editor={$cfg_editor}";
                         $action_label = $_SESSION['translate']->it("Select");
                         $action .= " || <a href=\"{$action_link}\">{$action_label}</a>";
                         $editor = $cfg_editor;
                     }
                 } else {
                     $status = $_SESSION['translate']->it("not installed");
                     $action_link = $this->linkRef . "&amp;action=addEditor&amp;addEditor={$cfg_editor}&amp;fn={$file}";
                     $action_label = $_SESSION['translate']->it("Install");
                     $action = "<a href=\"{$action_link}\">{$action_label}</a>";
                     $action_link = $this->linkRef . "&amp;action=delFile&amp;delFile={$cfg_editor}&amp;filetyp=ext";
                     $action_label = $_SESSION['translate']->it("Remove");
                     $action .= " || <a href=\"{$action_link}\">{$action_label}</a>";
                     $editor = $cfg_editor;
                 }
                 $table[] = array($location, $editor, $status, $action);
             }
         } else {
             $this->content .= "<br />" . $_SESSION['translate']->it("No local editors found");
         }
         if (!$GLOBALS["core"]->isHub) {
             $table[] = array("<b>" . $_SESSION['translate']->it("Location") . "</b>", "<b>" . $_SESSION['translate']->it("Editor") . "</b>", "<b>" . $_SESSION['translate']->it("Status") . "</b>", "<b>" . $_SESSION['translate']->it("Action") . "</b>");
             if (!is_dir("{$GLOBALS['core']->home_dir}files/xwysiwyg/")) {
                 PHPWS_File::makeDir($GLOBALS['core']->home_dir . "files/xwysiwyg/");
             }
             if (!is_dir("{$GLOBALS['core']->home_dir}files/xwysiwyg/editors/")) {
                 PHPWS_File::makeDir($GLOBALS['core']->home_dir . "files/xwysiwyg/editors/");
             }
             $dir = PHPWS_File::readDirectory(PHPWS_SOURCE_DIR . "files/xwysiwyg/editors/", FALSE, TRUE, FALSE, array('conf'));
             if (is_array($dir)) {
                 $location = $_SESSION['translate']->it("hub");
                 foreach ($dir as $file) {
                     include_once PHPWS_SOURCE_DIR . "files/xwysiwyg/editors/" . $file;
                     if (!in_array($cfg_editor, $editors)) {
                         $status = $_SESSION['translate']->it("not copied");
                         $action_link = $this->linkRef . "&amp;action=cpyEditor&amp;cpyEditor={$cfg_editor}";
                         $action_label = $_SESSION['translate']->it("Copy");
                         $action = "<a href=\"{$action_link}\">{$action_label}</a>";
                         $editor = $cfg_editor;
                     } else {
                         $status = $_SESSION['translate']->it("copied");
                         $action_link = $this->linkRef . "&amp;action=remEditor&amp;remEditor={$cfg_editor}";
                         $action_label = "";
                         $action = "na";
                         $editor = $cfg_editor;
                     }
                     $table[] = array($location, $editor, $status, $action);
                 }
             } else {
                 $this->content .= "<br />" . $_SESSION['translate']->it("No editors found on hub");
             }
         }
         $this->content .= PHPWS_Text::ezTable($table, 2, 2, 1, "", NULL, 1, "top");
         $this->content .= "<br /><br /><b>" . $_SESSION['translate']->it("Available editor-packages") . "</b>";
         $this->content .= "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"" . $this->linkRef . "&amp;action=manageEditor&amp;updList=1" . "\">" . $_SESSION['translate']->it("Update List") . "</a>";
         $table = array();
         $table[] = array("<b>" . $_SESSION['translate']->it("Location") . "</b>", "<b>" . $_SESSION['translate']->it("Editor") . "</b>", "<b>" . $_SESSION['translate']->it("Description") . "</b>", "<b>" . $_SESSION['translate']->it("Action") . "</b>");
         $dir = PHPWS_File::readDirectory(PHPWS_HOME_DIR . "files/xwysiwyg/editors/", FALSE, TRUE, FALSE, array('tgz'));
         if (is_array($dir)) {
             $location = $_SESSION['translate']->it("local");
             foreach ($dir as $file) {
                 $status = $_SESSION['translate']->it("Archive package");
                 $action_link = $this->linkRef . "&amp;action=tarEditor&amp;tarEditor={$file}&amp;local=1";
                 $action_label = $_SESSION['translate']->it("Extract");
                 $action = "<a href=\"{$action_link}\">{$action_label}</a>";
                 $action_link = $this->linkRef . "&amp;action=delFile&amp;delFile={$file}&amp;filetyp=tgz";
                 $action_label = $_SESSION['translate']->it("Delete");
                 $action .= " || <a href=\"{$action_link}\">{$action_label}</a>";
                 $editor = $file;
                 $table[] = array($location, $editor, $status, $action);
             }
         }
         // fixme: remeber to update this entry !
         $file_loc = PHPWS_HOME_DIR . "files/xwysiwyg/editors/list.txt";
         $file_onl = "http://www.firebird.ch/xwysiwyg/editors/list41.txt";
         $location = $_SESSION['translate']->it("remote");
         if (!is_file($file_loc)) {
             PHPWS_File::fileCopy($file_onl, PHPWS_HOME_DIR . "files/xwysiwyg/editors/", "list.txt", TRUE, TRUE);
         }
         if ($rows = file($file_loc)) {
             PHPWS_Array::dropNulls($rows);
             foreach ($rows as $items) {
                 $item = explode("::", $items);
                 $editor = $item[0];
                 if (in_array($editor, $editors)) {
                     continue;
                 }
                 $status = $item[1];
                 $action_label = $_SESSION['translate']->it("Direct install ([var1]kb)", $item[3]);
                 $action_link = $this->linkRef . "&amp;action=tarEditor&amp;tarEditor=" . $item[2];
                 $action = "<a href=\"{$action_link}\">{$action_label}</a>";
                 $action_label = $_SESSION['translate']->it("Download");
                 $action_link = "http://www.firebird.ch/xwysiwyg/editors/" . $item[2];
                 $action .= " || <a href=\"{$action_link}\" target=\"_blank\">{$action_label}</a>";
                 $table[] = array($location, $editor, $status, $action);
             }
         }
         $this->content .= PHPWS_Text::ezTable($table, 2, 2, 1, "", NULL, 1, "top");
         $this->content .= $_SESSION['translate']->it("Depending on your server's security settings, direct install may not work.") . "<br />";
         $this->content .= $_SESSION['translate']->it("If everything fails, or if you want to modify the editor,") . "<br />";
         $this->content .= $_SESSION['translate']->it("download the file and copy it to /_phpws_/files/xwysiwyg/editors/ manually") . "<br />";
     } else {
         $this->content .= $_SESSION['translate']->it("Access was denied due to lack of proper permissions.");
     }
     // End of ADMINISTRATOR condition
 }
Esempio n. 2
0
 /**
  * Creates a 2 dimensional array of items from the current table.
  *
  * This function creates an sql statement based on variables currently set in
  * this object.  The statement is then executed on the current table and it's
  * result is returned as the list of current items.
  *
  * @param  boolean $filterGroups Flag whether or not to filter items that are not
  *                 associated with a users group
  * @return mixed   A 2-dimentional array of items or FALSE on failure.
  * @access public
  * @see    getList()
  */
 function getItems($ids = NULL, $filterGroups = FALSE, $everything = FALSE)
 {
     if (isset($this->_table)) {
         $table = $this->_table;
     } else {
         $table = $this->_tables[$this->listName];
     }
     /* Make sure the table name is set before continuing */
     if (isset($table)) {
         if (is_array($this->_listColumns[$this->listName])) {
             if ($everything) {
                 $sql = 'SELECT *';
             } else {
                 $sql = 'SELECT id, ';
                 foreach ($this->_listColumns[$this->listName] as $listColumn => $listLabel) {
                     if ($listColumn != 'id') {
                         $sql .= $listColumn . ', ';
                     }
                 }
                 $sql = substr($sql, 0, strlen($sql) - 2);
             }
             $sql .= ' FROM ' . $table;
         } else {
             $error = new PHPWS_Error('core', 'PHPWS_Manager:getItems()', 'Format error in config file.', 'exit', 1);
             $error->message(NULL);
         }
     } else {
         $error = new PHPWS_Error('core', 'PHPWS_Manager:getItems()', 'Table not set!', 'exit', 1);
         $error->message(NULL);
     }
     $whereFlag = FALSE;
     $sort = $this->getSort();
     if (isset($sort)) {
         $sql .= $sort;
         $whereFlag = TRUE;
     }
     if (is_array($ids) && sizeof($ids) > 0) {
         if ($whereFlag) {
             $sql .= ' AND (';
         } else {
             $sql .= ' WHERE (';
         }
         foreach ($ids as $id) {
             $sql .= " id='{$id}' OR ";
         }
         $sql = substr($sql, 0, strlen($sql) - 4) . ')';
     }
     $order = $this->getOrder();
     if (isset($order)) {
         $sql .= $order;
     }
     /* Set associative mode for db and execute query */
     $result = PHPWS_DB::getAll($sql);
     if ($filterGroups) {
         $size = sizeof($result);
         for ($i = 0; $i < $size; $i++) {
             $groups = unserialize($result[$i]['groups']);
             if (is_array($groups)) {
                 foreach ($groups as $value) {
                     if (!$_SESSION['OBJ_user']->userInGroup($value)) {
                         unset($result[$i]);
                     }
                 }
             }
         }
         $result = PHPWS_Array::reIndex($result);
     }
     /* Return result of query */
     return $result;
 }