예제 #1
0
 /**
  * Получаем дерево разделов определённого меню
  *
  * @param int $menuId
  * @return array
  */
 public function getMenuTree($menuId)
 {
     $menu = $this->getMenu($menuId);
     if (!sizeof($menu)) {
         return array();
     }
     $sections = $this->_modelItems->fetchAll($this->_modelItems->select()->where('menu_id = ?', $menu->menu_id)->order('sort', 'item_id'));
     if ($menu->type == 'router') {
         $routerTree = Modules_Router_Model_Router::getInstance()->getItem($menu->parent_route_id);
         $_makeTreeFromRouter = function ($routerTree, $sections, $parentDisable) use(&$_makeTreeFromRouter) {
             $return = array();
             foreach ($routerTree as $i => $row) {
                 if (1 == $row['disable']) {
                     continue;
                 }
                 $return[$i] = $row;
                 $return[$i]['type'] = 'from_router';
                 $return[$i]['item_id'] = $row['route_id'];
                 $return[$i]['parent_id'] = $row['parent_route_id'];
                 $return[$i]['disable'] = $parentDisable;
                 unset($return[$i]['route_id'], $return[$i]['parent_route_id'], $return[$i]['childs']);
                 if (sizeof($sections)) {
                     foreach ($sections as $item) {
                         if ($item->route_id == $row['route_id']) {
                             $return[$i]['disable'] = $item->disable || $parentDisable;
                             $return[$i]['name'] = $item->name ? $item->name : $row['name'];
                         }
                     }
                 }
                 $return[$i]['childs'] = $_makeTreeFromRouter($row['childs'], $sections, $return[$i]['disable']);
             }
             return $return;
         };
         $sections = $_makeTreeFromRouter($routerTree['childs'], $sections, false);
     } else {
         $_makeUrl = function ($sections) use(&$_makeUrl) {
             $return = array();
             foreach ($sections as $i => $item) {
                 $return[$i] = $item;
                 if ($item['external_link']) {
                     $return[$i]['url'] = $item['external_link'];
                 } else {
                     $return[$i] += Modules_Router_Model_Router::getInstance()->getItem($item['route_id']);
                 }
                 $return[$i]['childs'] = $_makeUrl($item['childs']);
             }
             return $return;
         };
         $sections = System_Functions::toForest($sections->toArray(), 'item_id', 'parent_id');
         $sections = $_makeUrl($sections);
     }
     $this->_setCurrents($sections);
     return $sections;
 }
 /**
  * Returns array of all trusted/untrusted sites for given user identified
  * by $id
  *
  * @param string $id user identity URL
  * @return array
  */
 public function getTrustedSites($id)
 {
     $select = $this->_sitesTable->select()->where('openid = ?', $id);
     $rows = $this->_sitesTable->fetchAll($select);
     $array = $rows->toArray();
     $array['trusted'] = unserialize($array['trusted']);
     return $array;
 }
 public function getReceivers($pairs = false)
 {
     $triggersTable = new Zend_Db_Table('email_triggers_recipient');
     if ($pairs) {
         $select = $triggersTable->select();
         return $triggersTable->getAdapter()->fetchPairs($select);
     } else {
         return $triggersTable->fetchAll()->toArray();
     }
 }
예제 #4
0
 private function _init()
 {
     global $logger;
     $oTable = new Zend_Db_Table('path');
     foreach ($oTable->fetchAll($oTable->select())->toArray() as $xt) {
         $this->_path[] = $xt['name'];
     }
     $oTable = new Zend_Db_Table('container');
     $t = array();
     foreach ($oTable->fetchAll($oTable->select())->toArray() as $xt) {
         $t[] = $xt['name'];
     }
     $this->_extensions = implode(',', $t);
     $logger->log('Valid extensions are : ' . $this->_extensions, Zend_Log::DEBUG);
 }
예제 #5
0
 function getTable($name)
 {
     if (!($result = $this->_cache->load($this->_options[$name]['table']))) {
         $table = new Zend_Db_Table($this->_options[$name]['table']);
         if ($name == 'privilege') {
             $sql = new Zend_Db_Select($table->getDefaultAdapter());
             $sql->from(array('acl' => $this->_options['privilege']['table']), array('acl.ID_PERFIL'))->join(array('r' => $this->_options['resource']['table']), 'acl.ID_MENU=r.ID_MENU', array('r.URL_MENU', 'acl.PERMISO'));
             $result = $table->getAdapter()->fetchAll($sql);
         } else {
             $result = $table->fetchAll();
         }
         $this->_cache->save($result, $this->_options[$name]['table']);
     }
     return $result;
 }
예제 #6
0
 /**
  * retourne tous les parametres
  *
  * @return Settings
  */
 public function load()
 {
     global $logger;
     $this->_init();
     foreach ($this->_tables as $holder => $table) {
         $oTable = new Zend_Db_Table($table);
         $xt = array();
         foreach ($oTable->fetchAll($oTable->select()->order('id ASC'))->toArray() as $o) {
             $xsetting = new Setting();
             $xsetting->name = $o['name'];
             $xsetting->id = $o['id'];
             $xt[] = $xsetting;
         }
         $t[$holder] = $xt;
     }
     $s = new Settings($this->_description, $t[0], $t[1], $t[2], $t[3], $t[4], $t[5], $t[6], $t[7], $t[8]);
     return $s;
 }
예제 #7
0
파일: Client.php 프로젝트: staser/webacula
 public function fetchAll($where = null, $order = null, $count = null, $offset = null)
 {
     $res = parent::fetchAll($where, $order, $count, $offset)->toArray();
     // do Bacula ACLs
     return $this->bacula_acl->doBaculaAcl($res, 'name', 'client');
 }
예제 #8
0
파일: Core.php 프로젝트: hoalangoc/ftf
        public function getYnModulesOnYourSite($modules,$yours)
        {
            
            $lst_modules = array();
            $db = Engine_Api::_()->getDbtable('license', 'younetcore')->getAdapter();
            if( $db ) {
                try {
                    $table = new Zend_Db_Table(array(
                    'adapter' => $db,
                    'name' => 'engine4_core_modules',
                    ));
                    foreach( $table->fetchAll() as $row ) {
                        $lst_modules[$row->name] = $row->toArray();
                    }
                } catch( Exception $e ) {

                }
            }
            $modules_yn = array();
            if(count($lst_modules)>0)
            {
                foreach($lst_modules as $key =>$m)
                {
                    $t = false;
                    if(count($yours) >0)
                    {
                        if(array_key_exists($m['name'],$yours))
                        {
                            $t = true;
                        }
                    }
                    if(array_key_exists($m['name'],$modules) && $t == false && $m['name']!="younet-core")
                    {
                        if($this->checkMainifest($m['name']) == 2)
                        {
                            $modules_yn[$m['name']] = array(
                                'title' => $m['title'],
                                'name' => $m['name'],
                                'type' => 'module',
                                'current_version' => $m['version'],
                                'lasted_version' => $m['version'],
                                'is_active' =>$m['enabled'],
                                //'sort_description' =>$m['sort_description'],
                            );
                            $db->beginTransaction();
                            try {
                                $table = Engine_Api::_()->getDbtable('License', 'YounetCore');
                                $st = $table->createRow();
                                $st->setFromArray($modules_yn[$m['name']]);
                                $st->save();
                                $db->commit();
                            } catch (Exception $e) {
                                
                                $db->rollback();
                                //throw $e;
                            }
                        }
                        else
                        {
                            $db->beginTransaction();
                            try {
                                $table = Engine_Api::_()->getDbtable('License', 'YounetCore');
                                $where = $table->getAdapter()->quoteInto('name = ?', $m['name']);
                                $table->delete($where);
                                $db->commit();
                            } catch (Exception $e) {
                                
                                $db->rollback();
                                //throw $e;
                            }
                        }
                        
                        
                        
                    }

                }
            }
            return $modules_yn;
        }
예제 #9
0
파일: User.php 프로젝트: Arteaga2k/nolotiro
 public function fetchUserFriends($id)
 {
     $id = (int) $id;
     $table = new Zend_Db_Table('friends');
     $select = $table->select()->setIntegrityCheck(false);
     $select->from(array('f' => 'friends'), array('f.id_friend'));
     $select->where('f.id_user = ?', $id);
     $select->joinInner(array('u' => 'users'), 'f.id_friend = u.id', array('u.username'));
     return $table->fetchAll($select)->toArray();
 }
예제 #10
0
파일: Abstract.php 프로젝트: jaybill/Bolts
 public function fetchAll($where = null, $order = null, $count = null, $offset = null)
 {
     $result = parent::fetchAll($where, $order, $count, $offset);
     return $result;
 }
 /**
  * adds "start_date", "end_date" to contract and removes "status", "cleared", "cleared_in"
  */
 protected function _updateContractsFields()
 {
     $adminGroup = Tinebase_Group::getInstance()->getDefaultAdminGroup();
     $groupMembers = Tinebase_Group::getInstance()->getGroupMembers($adminGroup->getId());
     if (count($groupMembers) > 0) {
         $user = Tinebase_User::getInstance()->getUserById($groupMembers[0]);
         Tinebase_Core::set(Tinebase_Core::USER, $user);
         // cleared, cleared_in, status gets deleted, if the update is not called on cli
         $controller = Sales_Controller_Contract::getInstance();
         $table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array('id' => array('name' => 'id'), 'status' => array('name' => 'status'), 'cleared' => array('name' => 'cleared'), 'cleared_in' => array('name' => 'cleared_in'), 'description' => array('name' => 'description'), 'last_modified_time' => array('name' => 'last_modified_time'))));
         $count = 50;
         $offset = 0;
         $more = true;
         $updateDescription = $statusConfig = $clearedConfig = $setEndDate = array();
         $appId = Tinebase_Application::getInstance()->getApplicationByName('Tinebase')->getId();
         $pref = Tinebase_Core::getPreference('Tinebase');
         Tinebase_Core::setupUserLocale($pref->locale);
         $t = Tinebase_Translation::getTranslation('Sales', Tinebase_Core::getLocale());
         $config = Sales_Config::getInstance()->get('contractStatus');
         foreach ($config['records'] as $cfg) {
             $statusConfig[$cfg['id']] = $cfg['value'];
         }
         $config = Sales_Config::getInstance()->get('contractCleared');
         foreach ($config['records'] as $cfg) {
             $clearedConfig[$cfg['id']] = $cfg['value'];
         }
         while ($more) {
             $results = $table->fetchAll(NULL, NULL, $count, $offset)->toArray();
             foreach ($results as $row) {
                 if ($row['status'] == 'CLOSED') {
                     $setEndDate[$row['id']] = $row['last_modified_time'];
                 }
                 $desc = $row['description'];
                 $desc .= PHP_EOL . '---' . PHP_EOL . PHP_EOL;
                 $contents = FALSE;
                 if (!empty($row['status'])) {
                     $desc .= $t->_('Status') . ': ';
                     $desc .= isset($statusConfig[$row['status']]) ? $t->_($statusConfig[$row['status']]) : $row['status'];
                     $desc .= PHP_EOL;
                     $contents = TRUE;
                 }
                 if (!empty($row['cleared'])) {
                     $desc .= $t->_('Cleared') . ': ';
                     $desc .= isset($clearedConfig[$row['cleared']]) ? $t->_($clearedConfig[$row['cleared']]) : $row['cleared'];
                     $desc .= PHP_EOL;
                     $contents = TRUE;
                 }
                 if (!empty($row['cleared_in'])) {
                     $desc .= $t->_('Cleared In') . ': ';
                     $desc .= $row['cleared_in'];
                     $desc .= PHP_EOL;
                     $contents = TRUE;
                 }
                 if ($contents) {
                     $updateDescription[$row['id']] = $desc . PHP_EOL;
                 }
             }
             if (count($updateDescription) > 50) {
                 foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
                     $contr->description = $updateDescription[$contr->getId()];
                     $controller->update($contr, FALSE);
                 }
                 $updateDescription = array();
             }
             if (count($results) < $count) {
                 $more = FALSE;
             } else {
                 $offset = $offset + $count;
             }
         }
         try {
             foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
                 $contr->description = $updateDescription[$contr->getId()];
                 $controller->update($contr, FALSE);
             }
         } catch (Tinebase_Exception_AccessDenied $tead) {
             // could not update contracts ...
             Tinebase_Exception::log($tead);
         }
     }
     // remove deprecated sales contract fields
     foreach (array('status', 'cleared_in', 'cleared') as $colToDrop) {
         try {
             $this->_backend->dropCol('sales_contracts', $colToDrop);
         } catch (Zend_Db_Statement_Exception $zdse) {
             Tinebase_Exception::log($zdse);
         }
     }
     // add new sales contract fields
     $fields = array('<field>
         <name>start_date</name>
         <type>datetime</type>
     </field>', '
     <field>
         <name>end_date</name>
         <type>datetime</type>
     </field>');
     foreach ($fields as $field) {
         try {
             $declaration = new Setup_Backend_Schema_Field_Xml($field);
             $this->_backend->addCol('sales_contracts', $declaration);
         } catch (Zend_Db_Statement_Exception $zdse) {
             Tinebase_Exception::log($zdse);
         }
     }
     $table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array('id' => array('name' => 'id'), 'last_modified_time' => array('name' => 'last_modified_time'), 'end_date' => array('name' => 'end_date'), 'start_date' => array('name' => 'start_date'))));
     $db = $table->getAdapter();
     $values = array_keys($setEndDate);
     if (!empty($values)) {
         $sql = 'UPDATE ' . $db->quoteIdentifier(SQL_TABLE_PREFIX . 'sales_contracts') . ' SET ' . $db->quoteIdentifier('start_date') . ' = ' . $db->quoteIdentifier('last_modified_time') . ', ' . $db->quoteIdentifier('end_date') . ' = ' . $db->quoteIdentifier('last_modified_time') . ' WHERE ' . $db->quoteIdentifier('id') . $db->quoteInto(' IN (?)', $values);
         $db->query($sql);
     }
     if ($this->getTableVersion('sales_contracts') == 5) {
         $this->setTableVersion('sales_contracts', 6);
     } else {
         $this->setTableVersion('sales_contracts', 7);
     }
 }
예제 #12
0
파일: Table.php 프로젝트: xinghao/shs
 public function fetchAllMaster($where = null, $order = null, $count = null, $offset = null)
 {
     $this->_db = CrFramework_Db_Control::getMasterAdapter();
     $this->setDefaultAdapter($this->_db);
     logStd(get_class($this) . '->fetchAll()', 'Read from MASTER');
     $rowset = parent::fetchAll($where, $order, $count, $offset);
     return $rowset;
 }
예제 #13
0
 public function indexAction()
 {
     $contact = new Zend_Db_Table('contacts');
     $query = $contact->select()->order('name');
     $this->view->contacts = $contact->fetchAll($query);
 }
예제 #14
0
파일: Ad.php 프로젝트: Arteaga2k/nolotiro
 public function getAdListAllHome($ad_type)
 {
     $table = new Zend_Db_Table('ads');
     $select = $table->select()->setIntegrityCheck(false);
     $select->from(array('a' => 'ads'), array('a.*'));
     $select->joinLeft(array('c' => 'commentsAdCount'), 'a.id = c.id_comment', array('c.count as comments_count'));
     $select->joinLeft(array('r' => 'readedAdCount'), 'a.id = r.id_ad', array('r.counter as readings_count'));
     $select->join(array('u' => 'users'), 'a.user_owner = u.id', array('u.username'));
     //show only if user is active and not locked
     $select->where('u.active = ?', 1);
     $select->where('u.locked = ?', 0);
     $select->where('a.type = ?', $ad_type);
     $select->where('a.status = ?', 'available');
     $select->order('a.date_created DESC');
     $select->limit(20);
     $result = $table->fetchAll($select)->toArray();
     return $result;
 }
예제 #15
0
 /**
  * get messages in a thread
  *
  * @param thread_id
  * @return array of messages
  */
 public function getMessagesFromThread($id)
 {
     if (!$id) {
         return null;
     }
     $messages_table = new Zend_Db_Table('messages');
     $select = $messages_table->select()->setIntegrityCheck(false)->from('messages', array('user_from', 'user_to', 'date_created', 'body'))->where('thread_id = ?', $id)->join(array('u' => 'users'), 'user_from = u.id', array('username_from' => 'u.username'))->order('date_created');
     $result = $messages_table->fetchAll($select)->toArray();
     return $result;
 }
 public function indexAction()
 {
     // Check for updates
     try {
         $repo = $this->_packageManager->getRepository('socialengine.com');
         if ($repo) {
             $remoteVersions = $repo->queryList();
         }
     } catch (Exception $e) {
         // Silence
         $remoteVersions = array();
     }
     //$remoteVersions['core-base']['version'] = '4.0.0';
     $this->view->remoteVersions = $remoteVersions;
     // Try to get a list of installed modules and themes from the database
     $dbState = array();
     if (Zend_Registry::isRegistered('Zend_Db') && ($db = Zend_Registry::get('Zend_Db')) instanceof Zend_Db_Adapter_Abstract) {
         try {
             $table = new Zend_Db_Table(array('adapter' => $db, 'name' => 'engine4_core_modules'));
             foreach ($table->fetchAll() as $row) {
                 $dbState['module'][$row->name] = $row->toArray();
             }
         } catch (Exception $e) {
         }
         try {
             $table = new Zend_Db_Table(array('adapter' => $db, 'name' => 'engine4_core_themes'));
             foreach ($table->fetchAll() as $row) {
                 $dbState['theme'][$row->name] = $row->toArray();
             }
         } catch (Exception $e) {
         }
     }
     $this->view->dbState = $dbState;
     // List installed packages
     $upgradeablePackages = array();
     $pendingPackages = array();
     $installedPackages = array();
     foreach ($this->_packageManager->listInstalledPackages(array('caching' => false)) as $installedPackage) {
         // Get database state
         $databaseInfo = array();
         if (isset($dbState[$installedPackage->getType()][$installedPackage->getName()])) {
             $databaseInfo = $dbState[$installedPackage->getType()][$installedPackage->getName()];
         }
         // Get remote version info
         $remoteInfo = array();
         if (isset($remoteVersions[$installedPackage->getGuid()])) {
             $remoteInfo = $remoteVersions[$installedPackage->getGuid()];
         }
         //
         if ($installedPackage->getVersion() == '4.0.0beta3' && !empty($databaseInfo['version']) && $databaseInfo['version'] == '4.0.0') {
             $this->_forward('beta-update');
             return;
         }
         // Init
         $upgradeable = false;
         $pending = false;
         $navigation = array();
         // Navigation
         // Disable
         if (isset($databaseInfo['enabled']) && $databaseInfo['enabled'] && $installedPackage->hasAction('disable')) {
             $navigation[] = array('label' => 'disable', 'href' => $this->view->url(array('action' => 'disable')) . '?package=' . $installedPackage->getKey());
         }
         // Enable
         if (isset($databaseInfo['enabled']) && !$databaseInfo['enabled'] && $installedPackage->hasAction('enable')) {
             $navigation[] = array('label' => 'enable', 'href' => $this->view->url(array('action' => 'enable')) . '?package=' . $installedPackage->getKey());
         }
         // Install
         if ($installedPackage->getType() == 'module' && empty($databaseInfo['version'])) {
             $pending = true;
             $navigation[] = array('label' => 'install', 'href' => $this->view->url(array('action' => 'install')) . '?package=' . $installedPackage->getKey());
         }
         // Update/downgrade/refresh
         if ($installedPackage->getType() == 'module' && !empty($databaseInfo['version'])) {
             switch (version_compare($databaseInfo['version'], $installedPackage->getVersion())) {
                 case 1:
                     break;
                 case 0:
                     break;
                 case -1:
                     $pending = true;
                     $navigation[] = array('label' => 'upgrade', 'href' => $this->view->url(array('action' => 'install')) . '?package=' . $installedPackage->getKey());
                     break;
             }
         }
         // Remove
         if ($installedPackage->hasAction('remove')) {
             $navigation[] = array('label' => 'delete', 'href' => $this->view->url(array('action' => 'prepare')) . '?packages[]=' . $installedPackage->getKey() . '&actions[]=remove');
         }
         // Add get upgrade
         if (!empty($remoteInfo) && version_compare($remoteInfo['version'], $installedPackage->getVersion(), '>')) {
             $upgradeable = true;
             $navigation[] = array('label' => 'get update (' . $remoteInfo['version'] . ')', 'href' => 'http://www.socialengine.com/client');
         }
         $installedPackageInfo = array('package' => $installedPackage, 'database' => $databaseInfo, 'remote' => $remoteInfo, 'navigation' => $navigation, 'upgradeable' => $upgradeable, 'pending' => $pending);
         if ($upgradeable) {
             $upgradeablePackages[] = $installedPackageInfo;
         } else {
             if ($pending) {
                 $pendingPackages[] = $installedPackageInfo;
             } else {
                 $installedPackages[] = $installedPackageInfo;
             }
         }
     }
     $this->view->installedPackages = array_merge($upgradeablePackages, $pendingPackages, $installedPackages);
 }
 protected function _updateContractsWithUser($user)
 {
     Tinebase_Core::set(Tinebase_Core::USER, $user);
     // cleared, cleared_in, status gets deleted, if the update is not called on cli
     $controller = Sales_Controller_Contract::getInstance();
     $table = new Zend_Db_Table(SQL_TABLE_PREFIX . 'sales_contracts', new Zend_Db_Table_Definition(array('id' => array('name' => 'id'), 'status' => array('name' => 'status'), 'cleared' => array('name' => 'cleared'), 'cleared_in' => array('name' => 'cleared_in'), 'description' => array('name' => 'description'), 'last_modified_time' => array('name' => 'last_modified_time'))));
     $count = 50;
     $offset = 0;
     $more = true;
     $updateDescription = $statusConfig = $clearedConfig = $setEndDate = array();
     $pref = Tinebase_Core::getPreference('Tinebase');
     Tinebase_Core::setupUserLocale($pref->locale);
     $t = Tinebase_Translation::getTranslation('Sales', Tinebase_Core::getLocale());
     $config = Sales_Config::getInstance()->get('contractStatus');
     foreach ($config['records'] as $cfg) {
         $statusConfig[$cfg['id']] = $cfg['value'];
     }
     $config = Sales_Config::getInstance()->get('contractCleared');
     foreach ($config['records'] as $cfg) {
         $clearedConfig[$cfg['id']] = $cfg['value'];
     }
     while ($more) {
         $results = $table->fetchAll(NULL, NULL, $count, $offset)->toArray();
         foreach ($results as $row) {
             if ($row['status'] == 'CLOSED') {
                 $setEndDate[$row['id']] = $row['last_modified_time'];
             }
             $desc = $row['description'];
             $desc .= PHP_EOL . '---' . PHP_EOL . PHP_EOL;
             $contents = FALSE;
             if (!empty($row['status'])) {
                 $desc .= $t->_('Status') . ': ';
                 $desc .= isset($statusConfig[$row['status']]) ? $t->_($statusConfig[$row['status']]) : $row['status'];
                 $desc .= PHP_EOL;
                 $contents = TRUE;
             }
             if (!empty($row['cleared'])) {
                 $desc .= $t->_('Cleared') . ': ';
                 $desc .= isset($clearedConfig[$row['cleared']]) ? $t->_($clearedConfig[$row['cleared']]) : $row['cleared'];
                 $desc .= PHP_EOL;
                 $contents = TRUE;
             }
             if (!empty($row['cleared_in'])) {
                 $desc .= $t->_('Cleared In') . ': ';
                 $desc .= $row['cleared_in'];
                 $desc .= PHP_EOL;
                 $contents = TRUE;
             }
             if ($contents) {
                 $updateDescription[$row['id']] = $desc . PHP_EOL;
             }
         }
         if (count($updateDescription) > 50) {
             foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
                 $contr->description = $updateDescription[$contr->getId()];
                 $controller->update($contr, FALSE);
             }
             $updateDescription = array();
         }
         if (count($results) < $count) {
             $more = FALSE;
         } else {
             $offset = $offset + $count;
         }
     }
     try {
         foreach ($controller->getMultiple(array_keys($updateDescription)) as $contr) {
             $contr->description = $updateDescription[$contr->getId()];
             $controller->update($contr, FALSE);
         }
     } catch (Tinebase_Exception_AccessDenied $tead) {
         // could not update contracts ...
         Tinebase_Exception::log($tead);
     }
 }