Пример #1
0
 /**
  * Creates an Access shortcut and possibly menu link
  * @return boolean
  */
 public function createShortcut()
 {
     // title didn't change (in update or new) then go back
     if (!$this->_title_change) {
         return true;
     }
     PHPWS_Core::initModClass('access', 'Shortcut.php');
     PHPWS_Core::initModClass('menu', 'Menu.php');
     $key = new Key($this->key_id);
     $shortcut = new Access_Shortcut();
     $shortcut->setUrl($key->module, $key->url);
     $shortcut = new Access_Shortcut();
     $shortcut->setUrl('pagesmith', $key->url);
     $result = $shortcut->setKeyword($this->title);
     if (PHPWS_Error::isError($result) || $result == FALSE) {
         return $result;
     }
     $result = $shortcut->save();
     if (PHPWS_Error::isError($result) || $result == FALSE) {
         return $result;
     }
     if ($this->parent_page || !PHPWS_Settings::get('pagesmith', 'auto_link')) {
         return true;
     }
     return $this->createMenuShortcut($shortcut, $key);
 }
Пример #2
0
 public static function pageFix()
 {
     $db = new PHPWS_DB('ps_page');
     $db->addColumn('id');
     $db->addColumn('title');
     $db->setIndexBy('id');
     $all_pages = $db->select('col');
     if (empty($all_pages)) {
         return;
     }
     $db2 = new PHPWS_DB('access_shortcuts');
     $db2->addWhere('url', 'pagesmith:%', 'like');
     $db2->addColumn('url');
     $all_shortcuts = $db2->select('col');
     $current_page_ids = array();
     if (!empty($all_shortcuts)) {
         foreach ($all_shortcuts as $page) {
             $sc_array = explode(':', $page);
             $current_page_ids[] = array_pop($sc_array);
         }
     }
     PHPWS_Core::initModClass('access', 'Shortcut.php');
     foreach ($all_pages as $id => $title) {
         if (in_array($id, $current_page_ids)) {
             continue;
         }
         $shortcut = new Access_Shortcut();
         $shortcut->setKeyword($title);
         $shortcut->url = 'pagesmith:' . $id;
         $shortcut->active = 1;
         $shortcut->save();
     }
 }
Пример #3
0
 public function admin()
 {
     switch ($_REQUEST['dop']) {
         case 'delete_document':
             if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->document->delete();
             PHPWS_Core::returnToBookmark();
             break;
         case 'post_document_upload':
             if (!$this->folder->id || !Current_User::authorized('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->postDocumentUpload();
             javascript('close_refresh');
             Layout::nakedDisplay();
             //\PHPWS_Core::goBack();
             break;
         case 'upload_document_form':
             if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) {
                 Current_User::disallow();
             }
             $this->loadDocument(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT));
             $this->edit();
             echo Layout::wrap($this->content, 'Document Upload', true);
             exit;
         case 'add_access':
             if (!Current_User::authorized('filecabinet')) {
                 Current_User::disallow();
             }
             $keyword = null;
             $this->loadDocument();
             // document exists, try making a shortcut
             if ($this->document->id) {
                 PHPWS_Core::initModClass('access', 'Shortcut.php');
                 $shortcut = new Access_Shortcut();
                 if (isset($_GET['keyword'])) {
                     $keyword = $_GET['keyword'];
                 }
                 if (empty($keyword)) {
                     $keyword = $this->document->title;
                 }
                 $result = $shortcut->setKeyword($keyword);
                 $new_keyword = $shortcut->keyword;
                 // if setKeyword returns a false or error, we have them pick a different name
                 if (!$result || PHPWS_Error::isError($result)) {
                     $message = dgettext('filecabinet', 'Access shortcut name already in use. Please enter another.');
                     $success = false;
                 } else {
                     $shortcut->setUrl('filecabinet', $this->document->getViewLink());
                     $shortcut->save();
                     $success = true;
                     $message = '<p>' . dgettext('filecabinet', 'Access shortcut successful!') . '</p>';
                     $message .= '<a href="' . PHPWS_Core::getHomeHttp() . $shortcut->keyword . '">' . PHPWS_Core::getHomeHttp() . $shortcut->keyword . '</a>';
                 }
             } else {
                 $message = dgettext('filecabinet', 'File not found');
                 // not really a success but prevents a repost prompt
                 $success = true;
             }
             echo json_encode(array('success' => $success, 'message' => $message, 'keyword' => $new_keyword));
             exit;
     }
 }