Changeset 678


Ignore:
Timestamp:
Jul 26, 2014, 11:15:46 AM (10 years ago)
Author:
chronos
Message:
  • Přidáno: Oblíbené položky v nabídce.
  • Přidáno: Popis a povolení příjmu zpráv u kontaktů.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r677 r678  
    11<?php
    22
    3 $Revision = 677; // Subversion revision
    4 $DatabaseRevision = 676; // SQL structure revision
     3$Revision = 678; // Subversion revision
     4$DatabaseRevision = 678; // SQL structure revision
    55$ReleaseTime = strtotime('2014-07-25');
  • trunk/Common/Setup/Updates.php

    r677 r678  
    848848}
    849849
     850function UpdateTo678($Manager)
     851{
     852  $Manager->Execute('ALTER TABLE `Contact` ADD `Description` VARCHAR( 255 ) NOT NULL ;');
     853  $Manager->Execute('ALTER TABLE `Contact` ADD `Receive` BOOLEAN NOT NULL ;');
     854
     855  $Manager->Execute('CREATE TABLE IF NOT EXISTS `MenuItemFavorite` (
     856  `Id` int(11) NOT NULL AUTO_INCREMENT,
     857  `User` int(11) NOT NULL,
     858  `MenuItem` int(11) NOT NULL,
     859  PRIMARY KEY (`Id`),
     860  KEY `User` (`User`),
     861  KEY `MenuItem` (`MenuItem`)
     862) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     863
     864  $Manager->Execute('ALTER TABLE `MenuItemFavorite`
     865  ADD CONSTRAINT `MenuItemFavorite_ibfk_2` FOREIGN KEY (`MenuItem`) REFERENCES `MenuItem` (`Id`),
     866  ADD CONSTRAINT `MenuItemFavorite_ibfk_1` FOREIGN KEY (`User`) REFERENCES `User` (`Id`);');
     867
     868  $Manager->Execute('INSERT INTO `Action` (`Id` ,`Name` ,`Title` ,`Type` ,`URL` ,
     869`Group` ,`Icon` ,`PermissionOperation` ,`Enable`) VALUES (
     870NULL , "", "Oblíbené položky nabídky", "1", "/is/?t=MenuItemFavorite&a=list", NULL , NULL , NULL , "1");');
     871  $ActionId = $Manager->Database->insert_id;
     872  $DbResult = $Manager->Execute('SELECT `Id` FROM `MenuItem` WHERE `Name`="Nabídky"');
     873  if($DbResult->num_rows > 0)
     874  {
     875        $DbRow = $DbResult->fetch_assoc();
     876    $Manager->Execute("INSERT INTO `MenuItem` (`Id` ,`Name` ,`Parent` ,`Action` ,`Menu`) ".
     877      "VALUES (NULL , 'Oblíbené položky nabídky', ".$DbRow['Id'].", '".$ActionId."', '1');");
     878  }
     879}
     880
    850881class Updates
    851882{
     
    894925      671 => array('Revision' => 674, 'Function' => 'UpdateTo674'),
    895926      674 => array('Revision' => 676, 'Function' => 'UpdateTo676'),
     927      676 => array('Revision' => 678, 'Function' => 'UpdateTo678'),
    896928    ));
    897929  }
  • trunk/Modules/IS/IS.php

    r665 r678  
    2323    if(array_key_exists('i', $_GET)) $ItemId = $_GET['i'];
    2424      else $ItemId = 0;
     25    if(array_key_exists('menutype', $_COOKIE)) $MenuType = $_COOKIE['menutype'];
     26      else $MenuType = 0;
     27    if(array_key_exists('menutype', $_GET)) $MenuType = $_GET['menutype'] * 1;
     28    setcookie('menutype', $MenuType, time() + 60 * 60 * 24 * 365);
    2529
    2630    if($Action == 'list') $Content = $this->ShowList($Table);
     
    3236    else if($Action == 'view') $Content = $this->ShowView($Table, $ItemId);
    3337    else if($Action == 'delete') $Content = $this->ShowDelete($Table, $ItemId);
     38    else if($Action == 'fav_add') $Content = $this->ShowFavoriteAdd($Table, $ItemId);
     39    else if($Action == 'fav_del') $Content = $this->ShowFavoriteDel($Table, $ItemId);
    3440    else $Content = $this->Dashboard();
    3541    if($this->HideMenu == false)
    3642    {
    3743      $Output = '<table style="width: 100%"><tr><td style="width: 20%; vertical-align: top;">';
    38       $Output .= '<strong>Nabídka:</strong>'.$this->ShowMenu();
     44      $MenuTypeText = '<a href="?menutype=0">Nabídka</a>';
     45      if($MenuType == 0) $MenuTypeText = '<strong>'.$MenuTypeText.'</strong>';
     46      $Output .= $MenuTypeText.' ';
     47      $MenuTypeText = '<a href="?menutype=1">Oblíbené</a>';
     48      if($MenuType == 1) $MenuTypeText = '<strong>'.$MenuTypeText.'</strong>';
     49      $Output .= $MenuTypeText.' ';
     50      if($MenuType == 0) $Output .= $this->ShowMenu();
     51      if($MenuType == 1) $Output .= $this->ShowFavorites();
    3952      $Output .= '</td><td style="width: 80%; vertical-align: top;">';
    4053      $Output .= $Content;
     
    6982    $DbRow = $DbResult->fetch_row();
    7083    $Output .= 'Nezpárovaných plateb: '.$DbRow['0'].'<br/>';
     84    return($Output);
     85  }
     86
     87  function ShowFavoriteAdd($Table, $ItemId)
     88  {
     89    $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
     90    if($DbResult->num_rows > 0)
     91    {
     92      $Output = $this->SystemMessage('Oblíbené', 'Již existuje v oblíbených');
     93    } else {
     94      $this->Database->insert('MenuItemFavorite', array('MenuItem' => ($_GET['i'] * 1), 'User' => $this->System->User->User['Id']));
     95      $Output = $this->SystemMessage('Oblíbené', 'Přidáno do oblíbených');
     96    }
     97    $Output .= $this->ShowList($Table);
     98    return($Output);
     99  }
     100
     101  function ShowFavoriteDel($Table, $ItemId)
     102  {
     103    $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
     104    if($DbResult->num_rows > 0)
     105    {
     106      $DbRow = $DbResult->fetch_assoc();
     107      $this->Database->delete('MenuItemFavorite', '`Id`= '.$DbRow['Id']);
     108      $Output = $this->SystemMessage('Oblíbené', 'Odstraněno z oblíbených');
     109    } else {
     110      $Output = $this->SystemMessage('Oblíbené', 'Nenalezeno v oblíbených');
     111    }
     112    $Output .= $this->ShowList($Table);
    71113    return($Output);
    72114  }
     
    535577    $Output .= '<li><a href="?a=list&amp;t='.$Table.'"><img alt="Seznam" title="Seznam" src="'.
    536578      $this->System->Link('/images/list.png').'"/>Seznam</a></li>';
     579    $MI = 0;
     580    if(array_key_exists('mi', $_GET))
     581    {
     582      $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['mi'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
     583      if($DbResult->num_rows > 0)
     584      {
     585        $DbRow = $DbResult->fetch_assoc();
     586        $Fav = $DbRow['Id'];
     587        $Output .= '<li><a href="?a=fav_del&amp;t='.$Table.'&amp;i='.$_GET['mi'].'&amp;mi='.$_GET['mi'].'"><img alt="Odebrat z oblíbených" title="Odebrat z oblíbených" src="'.
     588          $this->System->Link('/images/Favorite-Del.png').'"/>Odebrat z oblíbených</a></li>';
     589      } else $Output .= '<li><a href="?a=fav_add&amp;t='.$Table.'&amp;i='.$_GET['mi'].'&amp;mi='.$_GET['mi'].'"><img alt="Přidat do oblíbených" title="Přidat do oblíbených" src="'.
     590          $this->System->Link('/images/Favorite-Add.png').'"/>Přidat do oblíbených</a></li>';
     591    }
    537592    if(array_key_exists('Actions', $FormClass))
    538593    {
     
    543598    $Output .= '</ul>';
    544599    return($Output);
     600  }
     601
     602  function ShowFavorites()
     603  {
     604    $this->MenuItems = array();
     605    $DbResult = $this->Database->query('SELECT `MenuItem`.`Id`, `MenuItem`.`Name`, `MenuItem`.`Parent`, `Action`.`URL` AS `URL`, `ActionIcon`.`Name` AS `IconName`, `Action`.`PermissionOperation` AS `Permission` FROM `MenuItemFavorite` ' .
     606      'LEFT JOIN `MenuItem` ON `MenuItem`.`Id` = `MenuItemFavorite`.`MenuItem` '.
     607      'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '.
     608      'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
     609      'WHERE `MenuItemFavorite`.`User`='.$this->System->User->User['Id'].' '.
     610      'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
     611    while($DbRow = $DbResult->fetch_assoc())
     612    {
     613      //if($DbRow['Permission'] != '')
     614      $this->MenuItems[$DbRow['Id']] = $DbRow;
     615    }
     616    return($this->ShowMenuItem('', true));
    545617  }
    546618
     
    561633  }
    562634
    563   function ShowMenuItem($Parent)
     635  function ShowMenuItem($Parent, $All = false)
    564636  {
    565637    $Output = '<ul style="list-style: none; margin-left:1em; padding-left:0em;">';
    566638    foreach($this->MenuItems as $MenuItem)
    567     if($MenuItem['Parent'] == $Parent)
     639    if(($MenuItem['Parent'] == $Parent) or $All)
    568640    {
    569641      $LinkTitle = $MenuItem['Name'];
     
    572644        $Icon = 'Device.png';
    573645        if(substr($MenuItem['URL'], 0, 4) != 'http') $MenuItem['URL'] = $this->System->Link($MenuItem['URL']);
    574         $LinkTitle = MakeLink($MenuItem['URL'], $LinkTitle);
     646        $LinkTitle = MakeLink($MenuItem['URL'].'&amp;mi='.$MenuItem['Id'], $LinkTitle);
    575647      } else $Icon = 'Folder.png';
    576648      if($MenuItem['IconName'] != '') $Image = '<img src="'.$this->System->Link('/images/favicons/'.$MenuItem['IconName']).'"/>&nbsp;';
     
    578650      //if($this->System->User->CheckPermission($this->TableToModule($Table), 'Write') or !defined('NEW_PERMISSION'))
    579651        $Output .= '<li>'.$Image.$LinkTitle.'</li>';
    580       $Output .= $this->ShowMenuItem($MenuItem['Id']);
     652      if($All == false) $Output .= $this->ShowMenuItem($MenuItem['Id']);
    581653    }
    582654    $Output .= '</ul>';
     
    631703      ),
    632704    ));
     705    $this->System->FormManager->RegisterClass('MenuItemFavorite', array(
     706      'Title' => 'Oblíbené položky nabídky',
     707      'Table' => 'MenuItemFavorite',
     708      'Items' => array(
     709        'User' => array('Type' => 'TUser', 'Caption' => 'Uživatele', 'Default' => '0'),
     710        'MenuItem' => array('Type' => 'TMenuItem', 'Caption' => 'Položka nabídky', 'Default' => '0'),
     711      ),
     712    ));
    633713    $this->System->FormManager->RegisterClass('Menu', array(
    634714      'Title' => 'Nabídky',
  • trunk/Modules/Subject/Subject.php

    r662 r678  
    8888        'User' => array('Type' => 'TUser', 'Caption' => 'Uživatel', 'Default' => '', 'Null' => true),
    8989        'Subject' => array('Type' => 'TSubject', 'Caption' => 'Subject', 'Default' => '', 'Null' => true),
     90        'Description' => array('Type' => 'String', 'Caption' => 'Popis', 'Default' => ''),
     91        'Receive' => array('Type' => 'Boolean', 'Caption' => 'Přijímat zprávy', 'Default' => '0'),
    9092      ),
    9193    ));
Note: See TracChangeset for help on using the changeset viewer.