ActionApps PHP Cross Reference Groupware Applications

Source: /central/index.php3 - 206 lines - 9960 bytes - Summary - Text - Print

Description: PHP versions 4 and 5

   1  <?php  //slice_id expected
   2  /**
   3   *
   4   *
   5   * PHP versions 4 and 5
   6   *
   7   * LICENSE: This program is free software; you can redistribute it and/or modify
   8   * it under the terms of the GNU General Public License as published by
   9   * the Free Software Foundation; either version 2 of the License, or
  10   * (at your option) any later version.
  11   *
  12   * This program is distributed in the hope that it will be useful,
  13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15   * GNU General Public License for more details.
  16   *
  17   * You should have received a copy of the GNU General Public License
  18   * along with this program (LICENSE); if not, write to the Free Software
  19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20   *
  21   * @version   $Id: index.php3 2404 2007-05-09 15:10:58Z honzam $
  22   * @author    Honza Malik <honza.malik@ecn.cz>
  23   * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
  24   * @copyright Copyright (C) 1999, 2000 Association for Progressive Communications
  25   * @link      http://www.apc.org/ APC
  26   *
  27  */
  28  
  29  // @todo only_action option which prints on the output the result of the action
  30  // Then it could be used as AJAX call for this action!
  31  
  32  require_once  "../include/init_page.php3";
  33  require_once  AA_INC_PATH . "varset.php3";
  34  require_once  AA_INC_PATH . "formutil.php3";
  35  require_once  AA_INC_PATH . "pagecache.php3";
  36  require_once  AA_INC_PATH . "item.php3";
  37  require_once  AA_INC_PATH . "manager.class.php3";
  38  require_once  AA_BASE_PATH. "central/include/actionapps.class.php";
  39  require_once  AA_BASE_PATH. "central/include/actions.php3";
  40  
  41  /** Function corresponding with 'actions' (see below) - returns true if user
  42   *  has the permission for the action. (The function must be called right
  43   *  before we perform/display action in order we have all variables set (r_state)
  44   *
  45   * @param  string  $action action to be displayed (in selectbox) / performed
  46   * @return bool    true if user has the permission
  47   */
  48  
  49  function CountItemsInBins() {
  50      $db = getDB();
  51  
  52      $ret['folder1'] = $ret['folder2'] = $ret['folder3'] = 0;
  53      $db->tquery("SELECT status_code, count(*) as cnt FROM central_conf
  54                   GROUP BY status_code");
  55                   while ( $db->next_record() ) {
  56                       $ret[ 'folder'. $db->f('status_code') ] = $db->f('cnt');
  57                   }
  58      return $ret;
  59  }
  60  
  61  if ( !IsSuperadmin() ) {
  62      MsgPage($sess->url(self_base())."index.php3", _m("You do not have permission to manage ActioApps instalations"));
  63      exit;
  64  }
  65  
  66  // we do not manage more "modules" here, so unique id is OK
  67  $module_id = '43656e7472616c2d41412d61646d696e';
  68  $metabase  = AA_Metabase::singleton();
  69  
  70  $actions   = new AA_Manageractions;
  71  $actions->addAction(new AA_Manageraction_Central_MoveItem('Activate', 1));
  72  $actions->addAction(new AA_Manageraction_Central_MoveItem('Folder2',  2));
  73  $actions->addAction(new AA_Manageraction_Central_MoveItem('Folder3',  3));
  74  $actions->addAction(new AA_Manageraction_Central_Sqlupdate('Sqlupdate_Test',   'dotest'));
  75  $actions->addAction(new AA_Manageraction_Central_Sqlupdate('Sqlupdate_Update', 'update'));
  76  $actions->addAction(new AA_Manageraction_Central_Linkcheck('Linkcheck'));
  77  $actions->addAction(new AA_Manageraction_Central_Optimize('Update_Db_Structure_Test',   'AA_Optimize_Update_Db_Structure', 'test'));
  78  $actions->addAction(new AA_Manageraction_Central_Optimize('Update_Db_Structure_Repair', 'AA_Optimize_Update_Db_Structure', 'repair'));
  79  $actions->addAction(new AA_Manageraction_Central_Optimize('Field_Duplicates_Test',      'AA_Optimize_Field_Duplicates', 'test'));
  80  $actions->addAction(new AA_Manageraction_Central_Optimize('Field_Duplicates_Repair',    'AA_Optimize_Field_Duplicates', 'repair'));
  81  $actions->addAction(new AA_Manageraction_Central_DeleteTrash('DeleteTrashAction',true));
  82  
  83  $switches  = new AA_Manageractions;
  84  
  85  // no problem to write tabs as one action, but we use 3
  86  $switches->addAction(new AA_Manageraction_Central_Tab('Tab1', 'app'));
  87  $switches->addAction(new AA_Manageraction_Central_Tab('Tab2', 'hold'));
  88  $switches->addAction(new AA_Manageraction_Central_Tab('Tab3', 'trash'));
  89  $switches->addAction(new AA_Manageraction_Central_DeleteTrash('DeleteTrash',false));
  90  
  91  function GetCentralAliases() {
  92      // fields: array('id', 'dns_conf', 'dns_serial', 'dns_web', 'dns_mx', 'dns_db', 'dns_prim', 'dns_sec', 'web_conf', 'web_path', 'db_server', 'db_name', 'db_user', 'db_pwd', 'AA_SITE_PATH', 'AA_BASE_DIR', 'AA_HTTP_DOMAIN', 'AA_ID', 'ORG_NAME', 'ERROR_REPORTING_EMAIL', 'ALERTS_EMAIL', 'IMG_UPLOAD_MAX_SIZE', 'IMG_UPLOAD_URL', 'IMG_UPLOAD_PATH', 'SCROLLER_LENGTH', 'FILEMAN_BASE_DIR', 'FILEMAN_BASE_URL', 'FILEMAN_UPLOAD_TIME_LIMIT', 'AA_ADMIN_USER', 'AA_ADMIN_PWD', 'status_code'));
  93      $aliases["_#ORG_NAME"] = GetAliasDef( "f_h", "ORG_NAME",       'ORG_NAME');
  94      $aliases["_#AA_ID___"] = GetAliasDef( "f_h", "AA_ID",          'AA_ID');
  95      $aliases["_#ID______"] = GetAliasDef( "f_h", "id",             'id');
  96      $aliases["_#DB_SERVE"] = GetAliasDef( "f_h", "db_server",      'db_server');
  97      $aliases["_#DB_NAME_"] = GetAliasDef( "f_h", "db_name",        'db_name');
  98      $aliases["_#HTTP_DOM"] = GetAliasDef( "f_h", "AA_HTTP_DOMAIN", 'AA_HTTP_DOMAIN');
  99      $aliases["_#AA_BASE_"] = GetAliasDef( "f_h", "AA_BASE_DIR",    'AA_BASE_DIR');
 100      return $aliases;
 101  }
 102  
 103  $manager_settings = array(
 104       'module_id' => $module_id,
 105       'show'      =>  MGR_ACTIONS | MGR_SB_SEARCHROWS | MGR_SB_ORDERROWS | MGR_SB_BOOKMARKS,    // MGR_ACTIONS | MGR_SB_SEARCHROWS | MGR_SB_ORDERROWS | MGR_SB_BOOKMARKS
 106       'searchbar' => array(
 107           'fields'               => $metabase->getSearchArray('central_conf'),
 108           'search_row_count_min' => 1,
 109           'order_row_count_min'  => 1,
 110           'add_empty_search_row' => true,
 111           'function'             => false  // name of function for aditional action hooked on standard filter action
 112                           ),
 113       'scroller'  => array(
 114           'listlen'              => ($listlen ? $listlen : EDIT_ITEM_COUNT)
 115                           ),
 116       'itemview'  => array(
 117           'manager_vid'          => false,    // $slice_info['manager_vid'],      // id of view which controls the design
 118           'format'               => array(    // optionaly to manager_vid you can set format array
 119               'compact_top'      => "<table border=0 cellspacing=0 cellpadding=5>",
 120               'category_sort'    => false,
 121               'category_format'  => "",
 122               'category_top'     => "",
 123               'category_bottom'  => "",
 124               'even_odd_differ'  => false,
 125               'even_row_format'  => "",
 126               'odd_row_format'   => '
 127                                      <tr class=tabtxt>
 128                                        <td width="30"><input type="checkbox" name="chb[_#ID______]" value=""></td>
 129                                        <td class=tabtxt><a href="'.$sess->url('tabledit.php3?cmd[centraledit][edit][_#ID______]=1').'"> _#ORG_NAME </a></td>
 130                                        <td class=tabtxt>_#AA_ID___</td>
 131                                        <td class=tabtxt>_#DB_SERVE - _#DB_NAME_</td>
 132                                        <td class=tabtxt>_#HTTP_DOM_#AA_BASE_</td>
 133                                      </tr>
 134                                      <tr class="tabtxt">
 135                                        <td>&nbsp;</td>
 136                                        <td class="tabtxt" colspan="4"><a href="{sessurl:?akce=Sqlupdate_Test&chb[_#ID______]=1}">'._m('sql_upadte TEST') .'</a> &nbsp; &nbsp; <a href="{sessurl:?akce=Sqlupdate_Update&chb[_#ID______]=1}">'._m('sql_upadte NOW!') .'</a></td>
 137                                      </tr>
 138                                     ',
 139               'compact_remove'   => "",
 140               'compact_bottom'   => "</table>",
 141               'id'               => $module_id ),
 142           'fields'               => $metabase->getSearchArray('central_conf'),
 143           'aliases'              => GetCentralAliases(),
 144           'get_content_funct'    => 'Central_GetAaContent'
 145                           ),
 146       'actions'   => $actions,
 147       'switches'  => $switches,
 148       'bin'       => 'app',
 149       'messages'  => array(
 150           'title'       => _m('ActionApps Central')
 151                           )
 152           );
 153  
 154  $manager = new AA_Manager($manager_settings);
 155  $profile = AA_Profile::getProfile($auth->auth["uid"], $module_id); // current user settings
 156  
 157  // r_state array holds all configuration of Links Manager
 158  // the configuration then could be Bookmarked
 159  if ( !isset($r_state) OR $change_id OR ($r_state["module_id"] != $module_id)) {
 160      // we are here for the first time or we are switching to another slice
 161      unset($r_state);
 162      // set default admin interface settings from user's profile
 163      $r_state["module_id"]       = $module_id;
 164      $sess->register('r_state');
 165  
 166      $manager->setFromProfile($profile);
 167  }
 168  
 169  if ($r_state['manager']) {        // do not set state for the first time calling
 170      $manager->setFromState($r_state['manager']);
 171  }
 172  
 173  $manager->performActions();
 174  
 175  // need for menu
 176  $r_state['bin_cnt'] = CountItemsInBins();
 177  
 178  $manager->printHtmlPageBegin(true);  // html, head, css, title, javascripts
 179  
 180  require_once  AA_INC_PATH."menu.php3";
 181  showMenu($aamenus, "central", $manager->getBin(), $navbar != "0", $leftbar != "0");
 182  
 183  $conds = $manager->getConds();
 184  $sort  = $manager->getSort();
 185  
 186  $BIN_CONDS   = array( 'app'    => AA_BIN_APPROVED,
 187                        'hold'   => AA_BIN_HOLDING,
 188                        'trash'  => AA_BIN_TRASH
 189                      );
 190  $zids = Central_QueryZids($conds, $sort, $BIN_CONDS[$manager->getBin()]);
 191  
 192  $manager->printSearchbarBegin();
 193  $manager->printSearchbarEnd();   // close the searchbar form
 194  
 195  $manager->printAndClearMessages();
 196  PrintArray($r_err);
 197  PrintArray($r_msg);
 198  unset($r_err);
 199  unset($r_msg);
 200  
 201  $manager->printItems($zids);   // print links and actions
 202  $r_state['manager'] = $manager->getState();
 203  
 204  HtmlPageEnd();
 205  page_close();
 206  ?>

title

Description

title

Description

title

Description

title

title

Body