コード例 #1
0
 public function aclconfigAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout()->disableLayout();
     $methods = get_class_methods('StudentController');
     $actions = array();
     foreach ($methods as $value) {
         $actions[] = substr("{$value}", 0, strpos($value, 'Action'));
     }
     foreach ($actions as $key => $value) {
         if ($value == null) {
             unset($actions[$key]);
         }
     }
     $db = new Zend_Db_Table();
     $delete2 = 'DELETE FROM `tnp`.`mod_role_resource` WHERE `module_id`=? AND `controller_id`=?';
     $db->getAdapter()->query($delete2, array('tnp', 'student'));
     $delete1 = 'DELETE FROM `tnp`.`mod_action` WHERE `module_id`=? AND `controller_id`=?';
     $db->getAdapter()->query($delete1, array('tnp', 'student'));
     print_r(sizeof($actions));
     $sql = 'INSERT INTO `tnp`.`mod_action`(`module_id`,`controller_id`,`action_id`) VALUES (?,?,?)';
     foreach ($actions as $action) {
         $bind = array('tnp', 'student', $action);
         $db->getAdapter()->query($sql, $bind);
     }
     $sql = 'INSERT INTO `tnp`.`mod_role_resource`(`role_id`,`module_id`,`controller_id`,`action_id`) VALUES (?,?,?,?)';
     foreach ($actions as $action) {
         $bind = array('student', 'tnp', 'student', $action);
         $db->getAdapter()->query($sql, $bind);
     }
 }
コード例 #2
0
ファイル: Comment.php プロジェクト: shevron/HumanHelp
 /**
  * Save object in DB
  * 
  * @return HumanHelp_Model_Comment
  */
 public function save()
 {
     $table = new Zend_Db_Table('comments');
     if (isset($this->_id)) {
         // Update
         $table->update($this->_data, $table->getAdapter()->quoteInto('id = ?', $this->_id));
     } else {
         // Insert
         $table->insert($this->_data);
         $this->_id = $table->getAdapter()->lastInsertId('comments', 'id');
     }
     return $this;
 }
コード例 #3
0
ファイル: SettingsMapper.php プロジェクト: ka2er/mmc-flex
 /**
  * Move down/up setting into the table
  */
 public function reorder($setting, $table, $sens)
 {
     global $logger;
     $cur_id = $setting->id;
     $other_id = $sens == 'up' ? $cur_id - 1 : $cur_id + 1;
     $oTable = new Zend_Db_Table($table);
     $where_cur = $oTable->getAdapter()->quoteInto('id = ?', $cur_id);
     $where_other = $oTable->getAdapter()->quoteInto('id = ?', $other_id);
     $where_tmp = $oTable->getAdapter()->quoteInto('id = ?', 999);
     $oTable->update(array('id' => 999), $where_cur);
     $oTable->update(array('id' => $cur_id), $where_other);
     $result = $oTable->update(array('id' => $other_id), $where_tmp);
     $logger->log("Reorder setting {$table}={$setting->id} {$sens}", Zend_Log::INFO);
     return $result;
 }
コード例 #4
0
ファイル: Comment.php プロジェクト: Arteaga2k/nolotiro
 public function updateCommentsAd($id, $count)
 {
     $id = (int) $id;
     $table = new Zend_Db_Table('commentsAdCount');
     $sql = "INSERT INTO commentsAdCount   ( id_comment, count ) VALUES  ( ?,? )\n                            ON DUPLICATE KEY UPDATE id_comment = ?, count = ?";
     $values = array("id_comment" => $id, "count" => $count);
     $result = $table->getAdapter()->query($sql, array_merge(array_values($values), array_values($values)));
 }
コード例 #5
0
 /**
  * @param string $prefix для формирования имен tmp таблиц
  * @param string $jobidHash хэш-индекс для массива jobid
  */
 public function __construct($jobidhash, $ttl_restore_session)
 {
     $this->db_adapter = Zend_Registry::get('DB_ADAPTER');
     $this->jobidhash = $jobidhash;
     $this->ttl_restore_session = $ttl_restore_session;
     // формируем имена временных таблиц
     $this->tmp_file = self::_PREFIX . 'file_' . $this->jobidhash;
     $config['db'] = Zend_Registry::get('db_bacula');
     // database
     $config['name'] = $this->_name;
     // name table
     $config['primary'] = $this->_primary;
     // primary key
     $config['sequence'] = true;
     parent::__construct($config);
     // setup DB adapter
     $this->_db = Zend_Db_Table::getAdapter('db_bacula');
     // существует ли таблица ?
     try {
         $this->_db->query('SELECT tmpId FROM ' . $this->_name . ' LIMIT 1');
     } catch (Zend_Exception $e) {
         // создаем таблицу
         switch ($this->db_adapter) {
             case 'PDO_MYSQL':
                 $sql = 'CREATE TABLE ' . $this->_name . ' (
                     tmpId    INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
                     tmpName  CHAR(64) UNIQUE NOT NULL,
                     tmpJobIdHash CHAR(64) NOT NULL,
                     tmpCreate   TIMESTAMP NOT NULL,
                     tmpIsCloneOk INTEGER DEFAULT 0,
                     PRIMARY KEY(tmpId)
                     )';
                 break;
             case 'PDO_PGSQL':
                 $sql = 'CREATE TABLE ' . $this->_name . ' (
                     tmpId    SERIAL NOT NULL,
                     tmpName  CHAR(64) UNIQUE NOT NULL,
                     tmpJobIdHash CHAR(64) NOT NULL,
                     tmpCreate   timestamp without time zone NOT NULL,
                     tmpIsCloneOk SMALLINT DEFAULT 0,
                     PRIMARY KEY(tmpId))';
                 break;
             case 'PDO_SQLITE':
                 $sql = 'CREATE TABLE ' . $this->_name . ' (
                    tmpId    INTEGER,
                    tmpName  CHAR(64) UNIQUE NOT NULL,
                    tmpJobIdHash CHAR(64) NOT NULL,
                    tmpCreate   TIMESTAMP NOT NULL,
                    tmpIsCloneOk INTEGER DEFAULT 0,
                    PRIMARY KEY(tmpId))';
                 break;
         }
         $this->_db->query($sql);
     }
 }
コード例 #6
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;
 }
コード例 #7
0
ファイル: Message.php プロジェクト: Arteaga2k/nolotiro
 /**
  * Deletes a new thread, by marking it as deleted. If both users deleted it
  * it is phisically deleted as well
  *
  * @param array $data: thread_id and user_id who is deleting
  */
 public function deleteThread(array $data)
 {
     /* Fetch thread */
     $threads_table = new Zend_Db_Table('threads');
     $select = $threads_table->select()->where('id = ?', $data['thread_id']);
     $thread = $threads_table->fetchRow($select);
     /* Update flags */
     if ($thread->user_from == $data['user_id']) {
         $thread->deleted_from = 1;
     } elseif ($thread->user_to == $data['user_id']) {
         $thread->deleted_to = 1;
     } else {
         return null;
     }
     $thread->save();
     /* If both deleted, delete physically */
     if ($thread->deleted_from && $thread->deleted_to) {
         $messages_table = new Zend_Db_Table('messages');
         $whereM = $messages_table->getAdapter()->quoteInto('id = ?', $data['thread_id']);
         $messages_table->delete($whereM);
         $thread->delete();
     }
     return;
 }
コード例 #8
0
 /**
  * LogBook full text search
  *
  */
 function findLogBookByText($id_text, $sort_order)
 {
     if (!isset($id_text)) {
         return;
     }
     $id_text = trim($id_text);
     $db = Zend_Db_Table::getAdapter('db_bacula');
     $select = new Zend_Db_Select($db);
     switch ($this->db_adapter) {
         case 'PDO_MYSQL':
             $select->distinct();
             $select->from(array('l' => 'webacula_logbook'), array('logId', 'logDateCreate', 'logDateLast', 'logTxt', 'logTypeId', 'logIsDel'));
             $select->joinLeft(array('t' => 'webacula_logtype'), 'l.logTypeId = t.typeId', array('typeId', 'typeDesc'));
             $select->where(' MATCH(logTxt) AGAINST ("' . $id_text . '" WITH QUERY EXPANSION)');
             break;
         case 'PDO_PGSQL':
             $select->distinct();
             $select->from(array('l' => 'webacula_logbook'), array('logId', 'logDateCreate', 'logDateLast', 'logTxt', 'logTypeId', 'logIsDel'));
             $select->joinLeft(array('t' => 'webacula_logtype'), 'l.logTypeId = t.typeId', array('typeId', 'typeDesc'));
             $str = preg_replace('/\\s+/', ' & ', $id_text);
             $select->where(" to_tsvector(logtxt) @@ to_tsquery(" . $db->quote($str) . ")");
             break;
         case 'PDO_SQLITE':
             // see also http://www.sqlite.org/cvstrac/wiki?p=FtsOne "FTS1 module is available in SQLite version 3.3.8 and later
             $select->distinct();
             $select->from(array('l' => 'webacula_logbook'), array('logid' => 'logId', 'logdatecreate' => 'logDateCreate', 'logdatelast' => 'logDateLast', 'logtxt' => 'logTxt', 'logtypeid' => 'logTypeId', 'logisdel' => 'logIsDel'));
             $select->joinLeft(array('t' => 'webacula_logtype'), 'l.logTypeId = t.typeId', array('typeid' => 'typeId', 'typedesc' => 'typeDesc'));
             $select->where(' logTxt LIKE  "%' . $id_text . '%"');
             break;
     }
     //$sql = $select->__toString(); echo "<pre>$sql</pre>"; exit; // for !!!debug!!!
     $result = $select->query();
     return $result;
 }
コード例 #9
0
ファイル: Wbjobdesc.php プロジェクト: staser/webacula
 public function init()
 {
     $db = Zend_Db_Table::getAdapter('db_bacula');
 }
コード例 #10
0
ファイル: User.php プロジェクト: Arteaga2k/nolotiro
 public function addUserFriend($id_user, $id_friend)
 {
     $id_user = (int) $id_user;
     $id_friend = (int) $id_friend;
     $table = new Zend_Db_Table('friends');
     $sql = "INSERT INTO friends   ( id_user, id_friend ) VALUES  ( {$id_user} , {$id_friend} )\n                            ON DUPLICATE KEY UPDATE  id_user=id_user";
     return $table->getAdapter()->query($sql)->fetch();
 }
コード例 #11
0
 public function manageAction()
 {
     $userForm = new Application_Form_User();
     $userForm->getElement('password')->setRequired(false);
     if ($this->getRequest()->isPost()) {
         //if we are updating
         $userId = $this->getRequest()->getParam('id');
         if ($userId) {
             $userForm->setId($userId);
         }
         if ($userForm->isValid($this->getRequest()->getParams())) {
             $data = $userForm->getValues();
             $user = new Application_Model_Models_User($data);
             Application_Model_Mappers_UserMapper::getInstance()->save($user);
             $this->_helper->response->success($this->_helper->language->translate('Saved'));
             exit;
         } else {
             $this->_helper->response->fail(Tools_Content_Tools::proccessFormMessages($userForm->getMessages()));
             exit;
         }
     }
     $pnum = (int) filter_var($this->getParam('pnum'), FILTER_SANITIZE_NUMBER_INT);
     $offset = 0;
     if ($pnum) {
         $offset = 10 * ($pnum - 1);
     }
     $select = $this->_zendDbTable->getAdapter()->select()->from('user');
     $by = filter_var($this->getParam('by', 'last_login'), FILTER_SANITIZE_STRING);
     $order = filter_var($this->getParam('order', 'desc'), FILTER_SANITIZE_STRING);
     $searchKey = filter_var($this->getParam('key'), FILTER_SANITIZE_STRING);
     if (!in_array($order, array('asc', 'desc'))) {
         $order = 'desc';
     }
     $select = $select->order($by . ' ' . $order);
     $paginatorOrderLink = '/by/' . $by . '/order/' . $order;
     if (!empty($searchKey)) {
         $select->where('email LIKE ?', '%' . $searchKey . '%')->orWhere('full_name LIKE ?', '%' . $searchKey . '%')->orWhere('role_id LIKE ?', '%' . $searchKey . '%')->orWhere('last_login LIKE ?', '%' . date("Y-m-d", strtotime($searchKey)) . '%')->orWhere('ipaddress LIKE ?', '%' . $searchKey . '%');
         $paginatorOrderLink .= '/key/' . $searchKey;
     }
     $adapter = new Zend_Paginator_Adapter_DbSelect($select);
     $users = $adapter->getItems($offset, 10);
     $userPaginator = new Zend_Paginator($adapter);
     $userPaginator->setCurrentPageNumber($pnum);
     $userPaginator->setItemCountPerPage(10);
     $pager = $this->view->paginationControl($userPaginator, 'Sliding', 'backend/user/pager.phtml', array('urlData' => $this->_websiteUrl . 'backend/backend_user/manage', 'order' => $paginatorOrderLink));
     if ($order === 'desc') {
         $order = 'asc';
     } else {
         $order = 'desc';
     }
     if (!empty($searchKey)) {
         $this->view->orderParam = $order . '/key/' . $searchKey;
     } else {
         $this->view->orderParam = $order;
     }
     $this->view->by = $by;
     $this->view->order = $order;
     $this->view->key = $searchKey;
     $this->view->pager = $pager;
     $this->view->users = $users;
     $this->view->helpSection = 'users';
     $this->view->userForm = $userForm;
 }
コード例 #12
0
 /**
  * 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]);
         if ($user->hasRight('Sales', Sales_Acl_Rights::ADMIN)) {
             $this->_updateContractsWithUser($user);
         }
     }
     // 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);
     }
 }
コード例 #13
0
ファイル: Menu.php プロジェクト: kytvi2p/ZettaFramework
 /**
  * Удаляем элемент меню
  *
  * @param int $item_id
  */
 public function deleteItem($item_id)
 {
     $where = $this->_modelItems->getAdapter()->quoteInto('item_id = ?', $item_id);
     $this->_modelItems->delete($where);
 }
コード例 #14
0
 /**
  * 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);
     }
 }
コード例 #15
0
ファイル: Ad.php プロジェクト: Arteaga2k/nolotiro
 public function updateReadedAd($id)
 {
     $table = new Zend_Db_Table('readedAdCount');
     $id = (int) $id;
     $sql = "INSERT INTO readedAdCount   ( id_ad, counter ) VALUES  ( {$id} , 1 )\n                            ON DUPLICATE KEY UPDATE  counter=counter+1";
     $table->getAdapter()->query($sql)->fetch();
 }
コード例 #16
0
 /**
  * Switching trigger statuses according to plugin status
  * @param $pluginName Name of plugin
  * @param $status Plugin status
  * @return Application_Model_Mappers_EmailTriggersMapper
  */
 public function toggleTriggersStatuses($pluginName, $status)
 {
     $triggers = $this->_getTriggers($pluginName);
     if (!empty($triggers)) {
         $triggersTable = new Zend_Db_Table('email_triggers');
         $triggersTable->getAdapter()->beginTransaction();
         foreach ($triggers as $trigger) {
             $triggersTable->update(array('enabled' => $status == Application_Model_Models_Plugin::DISABLED ? self::TRIGGER_STATUS_DISABLED : self::TRIGGER_STATUS_ENABLED), array('trigger_name = ?' => $trigger['trigger_name'], 'observer = ?' => $trigger['observer']));
         }
         $triggersTable->getAdapter()->commit();
     }
     return $this;
 }
コード例 #17
0
ファイル: IndexController.php プロジェクト: kangza/hagtag
 protected function setSystemAccessLog(&$data)
 {
     if ($this->_logAccess === 0 || !$data->use_id || isset($data->access_id)) {
         return $this;
     }
     require_once realpath(APPLICATION_PATH . '/../vendor/phpsniff-2.1.3/phpSniff.class.php');
     $_sniff = new phpSniff();
     $clientInfo = $_sniff->property();
     /**
      * @see Ht/Utils/Generater.php
      */
     try {
         Zend_Loader::loadClass("Ht_Utils_Generater");
         Zend_Loader::loadClass("Ht_Utils_Generater_Id");
         $generator = new Ht_Utils_Generater_Id(array(Ht_Utils_Generater::GENERATED_DIGIT32, Ht_Utils_Generater::GENERATED_INCLUDE_NUMBER, Ht_Utils_Generater::GENERATED_USE_LOWERLETTER, Ht_Utils_Generater::GENERATED_USE_UPPERLETTER));
         $access_id = $generator->getGeneratedId();
     } catch (Exception $exc) {
         echo $exc->getMessage(), "<hr />";
         echo $exc->getTraceAsString();
     }
     $row = array("access_id" => $access_id, "acc_id" => $data->u_id, "login_time" => new Zend_Db_Expr("NOW()"), "acc_ip" => $clientInfo["ip"], "acc_agent" => $clientInfo["ua"], "acc_browser" => $clientInfo["long_name"], "acc_os" => $clientInfo["os"]);
     unset($_sniff, $clientInfo);
     try {
         $sysaccess = new Default_Model_DbTable_SysAccess();
         $sysaccess->insert($row);
         $user = new Zend_Db_Table('ht_user');
         $where = $user->getAdapter()->quoteInto("use_id =?", $data->use_id);
         $user->update(array("use_lastlogin" => new Zend_Db_Expr("NOW()")), $where);
     } catch (Exception $exc) {
         $data->access_id = $access_id;
         return $this;
     }
     $data->access_id = $access_id;
     return $this;
 }
コード例 #18
0
ファイル: IndexController.php プロジェクト: kangza/hagtag
 public function logoutAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $auth = Zend_Auth::getInstance();
     $identity = $auth->getIdentity();
     try {
         $sysaccess = new Zend_Db_Table(array('name' => 'sys_access'));
         $sysaccess->update(array("logout_time" => new Zend_Db_Expr("NOW()")), $sysaccess->getAdapter()->quoteInto("access_id=?", $identity->access_id));
         $this->_dispatcher->notify(new sfEvent($this, 'authentication.log', array('message' => array(sprintf('`%s` logout success.', trim($identity->use_name . ' ' . $identity->use_lastname))), 'priority' => Zend_Log::INFO)));
         $auth->clearIdentity();
     } catch (Exception $e) {
         $this->_dispatcher->notify(new sfEvent($this, 'authentication.log', array('message' => array(sprintf('`%s` logout error.', trim($identity->use_name . ' ' . $identity->use_lastname)), $e->getMessage()), 'priority' => Zend_Log::ERR)));
     }
     $this->_redirect($this->_baseUrl);
 }