PlugincsSettingTable.class.php 1.14 KB
Newer Older
Яков's avatar
first  
Яков committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/*
 * Plugin table
 *
 * auto-generated by the sfDoctrine plugin
 * creation date: 2007-05-02 13:45:58
 */
class PlugincsSettingTable extends Doctrine_Table
{
  public function findAllForList()
  {
    return $this->findAll();
  }
  
  public function findSettingsByGroup($query)
  {
    return $query->addOrderBy($query->getRootAlias().'.setting_group ASC');
  }
  public function getExistingGroupsArray()
  {
    $groups = $this->createQuery()
                   ->groupBy('setting_group')
                   ->execute();
                   
    $groupArray = array();
    
    foreach ($groups as $group) 
    {
      $groupArray[$group['setting_group']] = $group['setting_group'];
    }
    return array_filter($groupArray);
  }
  
  public function getRestoreDefaultsQuery()
  {
    return $this->createQuery('s')
                ->update()
                ->set('s.value', 's.setting_default');
  }
  
  public function restoreAllDefaults()
  {
    return $this->getRestoreDefaultsQuery()->execute();
  }
  
  public function restoreDefault($id)
  {
    $q = $this->getRestoreDefaultsQuery()->addWhere('s.id = ?', $id);
    
    return $q->execute();
  }
}