当前位置: 首页>>代码示例>>PHP>>正文


PHP DaoFactory::create方法代码示例

本文整理汇总了PHP中DaoFactory::create方法的典型用法代码示例。如果您正苦于以下问题:PHP DaoFactory::create方法的具体用法?PHP DaoFactory::create怎么用?PHP DaoFactory::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DaoFactory的用法示例。


在下文中一共展示了DaoFactory::create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkPrivileges

	public function checkPrivileges($o)
	{
		$username=SC::get('userdata.username');
		if(in_array($username,array('dev1','dev2'))){
			return true;
			
		}
		
		$uid=SC::get('userdata.user_id');
		$dao=DaoFactory::create('user/admin');
		$dao->select('count(user_id) as count');
		$dao->byUserId($uid);
		$rs=$dao->execute();
		if(!$rs->isSuccess())
		{
			throw new CircuitDatabaseException('query admin users failed', $rs);
		}
		$count=$rs->fetchrow(DB_ASSOC);
        
		if($count['count']==0)
		{
	  		$message = "This page is not available under the current configuration, or ";
	      	$message .= "you are not authorized to view this page.";
	      	$o->set('error.message', $message);
	      	$o->set('error.code', GENERAL_MESSAGE);
	      	$o->set('error.title', 'Not Authorized');
	      	$o->set('error.line', __LINE__);
	      	$o->set('error.file', __FILE__);
			return false;
		}
		return true;
	}
开发者ID:GeniusXalid,项目名称:php-mvc,代码行数:32,代码来源:requiremsrpermissions.model.php

示例2: execute

 /**
  * Execute
  */
  function execute(&$observer)
  {
      
      // MOD RJH
      // Modification Date: 11-18-2004
      // Add Tracking for all actions into a single consolidated Admin Log Table
      // using Sushi to store data
      // TRACKING
      // ID (pk), USER ID(ind), IP(ind), datetime, request page, POST/GET
      if( preg_match("/^10./",$_SERVER['REMOTE_ADDR']) )  return TRUE;
     
      $GAIALOG = serialize(array($_GET,$_POST));
      $dao_logging =& DaoFactory::create('admincpanellog.insert');
      $dao_logging->setUserId(SC::get('userdata.user_id'));
      $dao_logging->setUsername(SC::get('userdata.username'));
      $dao_logging->setUserIp($_SERVER['REMOTE_ADDR']);
      $dao_logging->setDatetime(SC::get('board_config.time_now'));
      $dao_logging->setRequestFilename($_SERVER['SCRIPT_NAME']);
      $dao_logging->setRequestData($GAIALOG);
      $rs =& $dao_logging->execute();
      if(!$rs->isSuccess()) 
      {
          $observer->set('error.message', "Unable to connect to the database, please try again later.");
          $observer->set('error.title', 'Database Error');
          $observer->set('error.code', GENERAL_ERROR);
          $observer->set('error.line', __LINE__);
          $observer->set('error.file', __FILE__);
          return FALSE;
      }
      
      return TRUE;
      
  }
开发者ID:GeniusXalid,项目名称:php-mvc,代码行数:36,代码来源:adminaccesslog.model.php

示例3: swapItem

 public function swapItem($from_serial, $to_item_id, $user_id = NULL)
 {
     // default the user_id to the current logged in user if nothing was passed in
     $user_id = empty($user_id) ? SC::get('userdata.user_id') : intval($user_id);
     // validate that the serial we want to delete belongs to the user
     $ir = new InventoryReader($user_id);
     $ir->bySerial($from_serial);
     $rs = $ir->execute();
     if (!$rs->isSuccess()) {
         return $this->throwError('Unable to load your inventory at this time. Please try again later. Error: ' . $rs->getError(), $rs);
     }
     $data = $rs->getItems();
     // data is empty so that means the user doesn't own this serial
     if (empty($data)) {
         return $this->throwError('The item was not found in your inventory.');
     }
     // validate that the item we want to swap to exists
     // to_item_id can be either an INT (item_id that we want to grant) or
     // an array of item_ids that we want to grant and how many of each we want to grant
     // get the ids of the items we want to grant
     $item_ids = array();
     if (is_array($to_item_id)) {
         foreach ($to_item_id as $item) {
             $item_ids[] = $item['item_id'];
         }
     } else {
         $item_ids[] = $to_item_id;
     }
     // check to see if the items we want to grant exist
     $idr = new ItemDefinitionReader();
     $idr->addIds($item_ids);
     if (!$idr->execute('__meta__')) {
         return $this->throwError('Unable to load item detail, please try again. ' . $idr->getError(), $idr);
     }
     $found_ids = $idr->getItemIds();
     // if item_ids contains ids that arent in $found_ids then an item doesn't exist
     $difference = array_diff($item_ids, $found_ids);
     if (!empty($difference)) {
         return $this->throwError('Item(s) not found', $difference);
     }
     // at this point we have a valid serial that belongs to the user_id and valid items that we want to grant
     $txn = DaoFactory::create('transactionmanager');
     // clear frozen status (if any) as we should allow users to open frozen letters
     $prop = PropertyReader::instance()->getProperties($from_serial, $user_id);
     $from_item_frozen_property = NULL;
     if (isset($prop['frozen']) && FrozenChecker::isFrozenByProperty($prop)) {
         $from_item_frozen_property = $prop['frozen'];
         // would be nice if we can attach $txn to $iw here, but it would create a dirty read
         // problem. we could potentially fail later after clearing the frozen status. we will live
         // with the unlikely case for now.
         $iw = new InventoryWriter(IW_APPCODE_FUNC_SWAP_ITEM);
         $iw->deleteProperty($from_serial, $user_id, INVENTORY_LOCATION_MAIN, 'frozen');
         $iwr = $iw->execute();
         if (!$iwr->isSuccess()) {
             $txn->rollback();
             return $this->throwError($iwr->getError());
         }
     }
     //delete item we are swapping out
     $iw = new InventoryWriter(IW_APPCODE_FUNC_SWAP_ITEM, $txn);
     $iw->deleteSerializedItem($user_id, $from_serial);
     //grant item(s) we are swapping in
     if (is_array($to_item_id)) {
         foreach ($to_item_id as $item) {
             $quantity = isset($item['quantity']) ? $item['quantity'] : 1;
             $iw->grantNewItems($user_id, $item['item_id'], $quantity);
         }
     } else {
         $iw->grantNewItems($user_id, $to_item_id, 1);
     }
     $iwr = $iw->execute(FALSE);
     if (!$iwr->isSuccess()) {
         $txn->rollback();
         return $this->throwError($iwr->getError());
     }
     // get the serials of the granted items
     $this->granted_items = $iwr->getGeneratedSerials();
     if ($from_item_frozen_property) {
         // transfer the frozen property value to the swapped item
         // with packages it's not possible that a frozen item will grant multiple items.
         // all these items should be frozen
         $iw = new InventoryWriter(IW_APPCODE_FUNC_SWAP_ITEM, $txn);
         foreach ($this->granted_items as $new_serial) {
             $iw->setProperty($new_serial, $user_id, INVENTORY_LOCATION_MAIN, 'frozen', $from_item_frozen_property);
         }
         $iw->execute(FALSE);
         if (!$iwr->isSuccess()) {
             $txn->rollback();
             return $this->throwError($iwr->getError());
         }
     }
     $txn->commit();
     // set the new serials associated with the item_ids
     return TRUE;
 }
开发者ID:GeniusXalid,项目名称:php-mvc,代码行数:95,代码来源:items.model.php

示例4: start

 public function start()
 {
     return DaoFactory::create('transactionmanager');
 }
开发者ID:GeniusXalid,项目名称:php-mvc,代码行数:4,代码来源:transaction.model.php

示例5: testNoConnectorCreatedReturnsFalse

 public function testNoConnectorCreatedReturnsFalse()
 {
     return $this->assertFalse(DaoFactory::create('testdb.testtable', $this->test_map_file));
 }
开发者ID:relisher,项目名称:daonut,代码行数:4,代码来源:daofactory.stest.php

示例6: execute


//.........这里部分代码省略.........
             $observer->set('default.validation.status', 'Swear');
             $observer->set('login.request.status', 'Swear');
             return FALSE;
         }
     }
     //----------------------------------------------------------------------------------------
     // username approximate matching
     // we need to munge the name now and attempt to standardize the lookups
     $userdata =& SC::get('userdata');
     $username = str_replace("\\'", "''", $username);
     $checkname = strtolower(preg_replace("/^[_\\-\\+\\=\\)\\(\\^\\#\\!\\~\\'\\s\\.]+/", '', $username));
     $checkname = preg_replace("/[_\\-\\+\\=\\)\\(\\^\\#\\!\\~\\'\\s\\.]+\$/", '', $checkname);
     $checkname = preg_replace("/[\\-\\+\\=\\^\\#\\!\\~\\s\\.]/", '_', $checkname);
     // compressed length check
     if (strlen(trim($username)) <= 2) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Your username must be at least 3 characters.');
         return FALSE;
     }
     // invalid character check
     if (!preg_match('/^[a-zA-z0-9_\\-\\+\\=\\)\\(\\^\\#\\!\\~\\s\\.]+$/', $username)) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Your username contains invalid characters.');
         return FALSE;
     }
     // check for at least one letter
     if (!preg_match("/[a-zA-Z]/", $username)) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Your username must have at least one letter.');
         return FALSE;
     }
     // check for double spaces
     if (preg_match("/  /", $username)) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Your username cannot have 2 spaces in a row.');
         return FALSE;
     }
     // Don't allow " in username.
     if (strstr($username, '"') || strstr($username, ',')) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Your username cannot contain quotations or commas.');
         return FALSE;
     }
     // check for exact username
     $dao =& DaoFactory::create('users');
     $dao->byExactUsername(strtolower($username));
     $rs =& $dao->execute();
     if (!$rs->isSuccess()) {
         $observer->set('error.title', 'Username Error');
         $observer->set('error.message', 'Unable to validate username.');
         $observer->set('error.line', __LINE__);
         $observer->set('error.file', __FILE__);
         $observer->set('error.debug', $rs);
         return FALSE;
     }
     while ($row = $rs->sql_fetchrow(DB_ASSOC)) {
         if ($userdata['session_logged_in'] && $row['username'] != $userdata['username'] || !$userdata['session_logged_in']) {
             if (strtolower($row['username']) == strtolower($username)) {
                 $observer->set('error.title', 'Username Error');
                 $observer->set('error.message', 'That username is already taken.');
                 return FALSE;
             } else {
                 $observer->set('error.title', 'Username Error');
                 $observer->set('error.message', 'Your username is too similar to the username of ' . $row['username']);
                 return FALSE;
             }
         }
     }
     // perform a wildcard search for special character matching
     if (strtolower($username) != $checkname) {
         $dao =& DaoFactory::create('users');
         $dao->byUsername(preg_replace('/_/', '\\_', $checkname));
         $rs =& $dao->execute();
         while ($row = $rs->sql_fetchrow(DB_ASSOC)) {
             if ($userdata['session_logged_in'] && $row['username'] != $userdata['username'] || !$userdata['session_logged_in']) {
                 if (strtolower($row['username']) == strtolower($username)) {
                     $observer->set('error.title', 'Username Error');
                     $observer->set('error.message', 'That username is already taken.');
                     return FALSE;
                 } else {
                     $observer->set('error.title', 'Username Error');
                     $observer->set('error.message', 'Your username is too similar to the username of ' . $row['username']);
                     return FALSE;
                 }
             }
         }
     }
     // check wordlist filter
     $dao =& DaoFactory::create('words');
     $dao->setWhat('word');
     $rs =& $dao->execute();
     while ($row = $rs->sql_fetchrow(DB_ASSOC)) {
         if (preg_match("#\\b(" . str_replace("\\*", ".*?", phpbb_preg_quote($row['word'], '#')) . ")\\b#i", $username)) {
             $observer->set('error.title', 'Username Error');
             $observer->set('error.message', 'Your username contains invalid characters.');
             return FALSE;
         }
     }
     return TRUE;
 }
开发者ID:GeniusXalid,项目名称:php-mvc,代码行数:101,代码来源:validateusername.model.php


注:本文中的DaoFactory::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。