[ PHPXref.com ] [ Generated: Sun Jul 20 20:33:10 2008 ] [ TaskFreak! 0.1.4 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/install/ -> mysql.copy.php (source)

   1  <?php
   2  /****************************************************************************\
   3  * TaskFreak!                                                                 *
   4  * multi user                                                                 *
   5  ******************************************************************************
   6  * Version: 0.1.4                                                             *
   7  * Release date: 18 May 2006                                                  *
   8  * Authors: Stan Ozier <taskfreak@gmail.com>                                  *
   9  * License:  http://www.gnu.org/licenses/gpl.txt (GPL)                        *
  10  \****************************************************************************/
  11  
  12  if (!$pIsImported) {
  13      redirect('index.php');
  14      exit;
  15  }
  16  
  17  include PRJ_CLASS_PATH.'tzn_generic.php';
  18  include PRJ_CLASS_PATH.'tzn_mysql.php';
  19  include PRJ_CLASS_PATH.'tzn_user.php';
  20  include PRJ_CLASS_PATH.'pkg_member.php';
  21  include PRJ_CLASS_PATH.'pkg_project.php';
  22  
  23  class Task extends TznDb
  24  {
  25  	function Task()
  26      {
  27          parent::TznDb('task');
  28          $this->addProperties(array(
  29              'id'                 => 'UID',
  30              'priority'            => 'NUM',
  31              'project'            => 'STR',
  32              'context'            => 'STR',
  33              'title'                => 'STR',
  34              'description'        => 'BBS',
  35              'status'            => 'NUM',
  36              'creationDate'        => 'DTM',
  37              'lastChangeDate'    => 'DTM',
  38              'deadlineDate'        => 'DTE'
  39          ));
  40      }
  41  }
  42  
  43  $src_host = $dst_host = TZN_DB_HOST;
  44  $src_user = $dst_user = TZN_DB_USER;
  45  //$src_pass = $dst_pass = TZN_DB_PASS;
  46  $src_base = $dst_base = TZN_DB_BASE;
  47  $src_table = 'task';
  48  
  49  if ($_REQUEST['submit']) {
  50      $src_host = Tzn::getHttp($_POST['src_host']);
  51      $src_user = Tzn::getHttp($_POST['src_user']);
  52      $src_pass = Tzn::getHttp($_POST['src_pass']);
  53      $src_base = Tzn::getHttp($_POST['src_base']);
  54      $src_table = Tzn::getHttp($_POST['src_table']);
  55  
  56      $dst_host = Tzn::getHttp($_POST['dst_host']);
  57      $dst_user = Tzn::getHttp($_POST['dst_user']);
  58      $dst_pass = Tzn::getHttp($_POST['dst_pass']);
  59      $dst_base = Tzn::getHttp($_POST['dst_base']);
  60  
  61      $objProjectList =  new Member();
  62      $objProjectList->addOrder('level DESC,lastName ASC');
  63      $objProjectList->getConnection($dst_host, $dst_user, $dst_pass, $dst_base);
  64      $objProjectList->loadList();
  65  
  66      $arrProjectList = array();
  67      while ($objProject = $objProjectList->rNext()) {
  68          $arrProjectList[$objProject->name] = $arrProjectList->id;
  69      }
  70  
  71  }
  72  
  73  $objMemberList =  new Member();
  74  $objMemberList->addOrder('level DESC,lastName ASC');
  75  $objMemberList->getConnection($dst_host, $dst_user, $dst_pass, $dst_base);
  76  $objMemberList->loadList();
  77  
  78  ?>
  79  <div id="preview">
  80  <?php
  81  if (!$_REQUEST['submit']) {
  82  
  83  ?>
  84  <form method="POST">
  85    <input type="hidden" name="action" value="4" />
  86    <center>
  87      <table cellpadding="4" cellspacing="0" border="0">
  88          <tr>
  89              <th>Source<br />(single version)</th>
  90              <th></th>
  91              <th>Destination<br />(multiple version)</th>
  92          </tr>
  93          <tr>
  94              <td style="font-family: monospace" valign="top">
  95                  Host &nbsp; &nbsp; : <input type="text" name="src_host" value="<?php echo $src_host; ?>" /><br />
  96                  User &nbsp; &nbsp; : <input type="text" name="src_user" value="<?php echo $src_user; ?>" /><br />
  97                  Pass &nbsp; &nbsp; : <input type="password" name="src_pass" value="<?php echo $src_pass; ?>" /><br />
  98                  Database : <input type="text" name="src_base" value="<?php echo $src_base; ?>" /><br />
  99                  Table &nbsp; &nbsp;: <input type="text" name="src_table" value="<?php echo $src_table; ?>" />
 100              </td>
 101              <td style="font-family: monospace" valign="middle"><big>&nbsp;--&gt;&nbsp;</big></td>
 102              <td style="font-family: monospace" valign="top">
 103                  Host &nbsp; &nbsp; : <input type="text" name="dst_host" value="<?php echo $dst_host; ?>" /><br />
 104                  User &nbsp; &nbsp; : <input type="text" name="dst_user" value="<?php echo $dst_user; ?>" /><br />
 105                  Pass &nbsp; &nbsp; : <input type="password" name="dst_pass" value="<?php echo $dst_pass; ?>" /><br />
 106                  Database : <input type="text" name="dst_base" value="<?php echo $dst_base; ?>" />
 107              </td>
 108          </tr>
 109      </table>
 110      <div style="text-align:left;width:300px">
 111          <br />
 112          <input type="radio" name="user_mode" value="1" onclick="hD(gE('user_context'))" checked="checked" /> Assign tasks to 
 113          <?php $objMemberList->qSelect('user_list','username','','- nobody -'); ?><br />
 114          <input type="radio" name="user_mode" value="2" onclick="sD(gE('user_context'))" /> Auto assign tasks from context field
 115          <div id="user_context" style="margin:0px 0px 0px 25px;padding:5px;background-color:#fcfcfc;display:none">
 116              <table cellpadding="2" cellspacing="0" border="0">
 117                  <tr>
 118                      <th style="text-align:left">Context<br />Code (source)</th>
 119                      <th>&nbsp;</th>
 120                      <th style="text-align:left">User<br />(destination)</th>
 121                      <th>&nbsp;</th>
 122                  </tr>
 123                  <?php
 124                  $objMemberList->rReset();
 125                  while($objMember = $objMemberList->rNext()) {
 126                  ?>
 127                  <tr>
 128                      <td><input type="text" name="user_context[<?php echo $objMember->id; ?>]" style="width:90px"></td>
 129                      <td>-&gt;</td>
 130                      <td><?php echo $objMember->getShortName(); ?></td>
 131                  </tr>
 132                  <?php
 133                  }
 134                  ?>
 135              </table>
 136          </div>
 137      </div><br />
 138      <div>* Please make sure you had backup your data before trying this *<br />
 139      <input type="submit" name="submit" value="Import tasks" /></div>
 140    </center>
 141  </form>
 142  <?php
 143  
 144  } else {
 145  
 146      $objSrcList = new Task();
 147      $objSrcList->addOrder('deadlineDate ASC');
 148      $objSrcList->getConnection($src_host, $src_user, $src_pass, $src_base);
 149      $objSrcList->loadList('SELECT * FROM '.$_REQUEST['src_table']);
 150      echo '<p>Importing Tasks from table <b>'.$_REQUEST['src_table'].'</b> in database <b>'.$src_base.'/'.$objSrcList->_dbConnection->_dbBase
 151          .'</b><br />Please wait....</p>';
 152  
 153      if ($objSrcList->rNext()) {
 154  
 155          $i=0;
 156          $pSqlNow = gmdate('Y-m-d',time()-(3600*24*3));
 157          while ($objSrc = $objSrcList->rNext()) {
 158  
 159              $objItem = new Item();
 160              
 161              $objItem->priority = $objSrc->priority;
 162              $objItem->context = 1;
 163              $objItem->title = $objSrc->title;
 164              $objItem->description = $objSrc->description;
 165              $objItem->deadlineDate = $objSrc->deadlineDate;
 166              
 167              // check user
 168              $pUserId = $_REQUEST['user_list'];
 169              if ($_REQUEST['user_mode'] == 2) {
 170                  $pUserId = array_search($objSrc->context,$_REQUEST['user_context']);
 171                  $objItem->member->id = $pUserId;
 172                  $objItem->authorId = ($pUserId)?$pUserId:1;
 173              } else {
 174                  $objItem->member->id = $pUserId;
 175                  $objItem->member->id = $pUserId;
 176              }
 177  
 178              // check project
 179              $pProjectId = $arrProjectList[$objSrc->project];
 180              if (!array_key_exists($objSrc->project,$arrProjectList)) {
 181                  // create project
 182                  $objProject = new Project();
 183                  $objProject->name=$objSrc->project;
 184                  $objProject->getConnection($dst_host, $dst_user, $dst_pass, $dst_base);
 185                  $objProject->add(1,1);
 186                  $arrProjectList[$objSrc->project] = $objProject->id;
 187                  $pProjectId = $objProject->id;
 188              }
 189              $objItem->project->id = $pProjectId;
 190              
 191              $objItem->getConnection($dst_host, $dst_user, $dst_pass, $dst_base);
 192              $objItem->add();
 193  
 194              $objItemStatus = new ItemStatus();
 195              $objItemStatus->itemId = $objItem->id;
 196              $objItemStatus->member->id = ($pUserId)?$pUserId:1;
 197              $objItemStatus->statusKey = $objSrc->status;
 198              $objItemStatus->statusDate = $pSqlNow;
 199              $objItemStatus->getConnection($dst_host, $dst_user, $dst_pass, $dst_base);
 200              $objItemStatus->add();
 201  
 202              $objItem->itemStatus->id = $objItemStatus->id;
 203  
 204              $objItem->update('itemStatus');
 205  
 206              echo '.';
 207              if (++$i % 50 == 0) {
 208                  echo "<br />\n";
 209                  usleep(500);
 210              }
 211          }
 212  
 213          echo '<p class="ok">'.$i.' tasks imported!! Good job!</p>';
 214  
 215      }
 216  ?>
 217  <?php
 218  }
 219  ?>
 220  </div>


[ Powered by PHPXref - Served by Debian GNU/Linux ]