예제 #1
0
 public static function assignTarget($from_user_id, $to_user_id)
 {
     $target = new Target();
     $target->setFromUserId($from_user_id);
     $target->setToUserId($to_user_id);
     $target->save();
 }
 /**
  * Constructor
  * @param $project the project to which this antxml context belongs to
  */
 public function __construct($project)
 {
     $this->project = $project;
     $this->implicitTarget = new Target();
     $this->implicitTarget->setName("");
     $this->implicitTarget->setHidden(true);
 }
예제 #3
0
 /**
  * @test
  * @covers \Bytes\Component::Controller
  * @expectedException \Bytes\ComponentException
  * @expectedExceptionMessageRegExp /Method \w+ not found in controller \w+/
  */
 public function Controller_NoMethod()
 {
     $Component = new Target();
     $OB = new \Bytes\ObjectBuilder();
     $OB->SetInjectionContainer(new \Bytes\InjectionContainer());
     $Component->SetDirectory(__DIR__ . '/Components/SampleComponent/')->SetObjectBuilder($OB)->Initialize(new \Bytes\Router());
     $Output = $Component->Controller('Index', 'Foobar');
 }
예제 #4
0
 /**
  * Test the Backup collector with no dynamic directory
  * Files not matching foo-%d.txt.zip should be ignored.
  */
 public function testMatchFilesCompressed()
 {
     $path = $this->getTestDataDir() . '/collector/static-dir-compressed';
     $filename = 'foo-%d.txt';
     $target = new Target($path, $filename, strtotime('2014-12-01 04:30:57'));
     $target->setCompressor($this->getCompressorMockForCmd('zip', 'zip'));
     $collector = new Collector($target);
     $files = $collector->getBackupFiles();
     $this->assertEquals(4, count($files), '4 files should be found');
 }
 public static function create($distance = null, $health = null)
 {
     $target = new Target();
     if ($distance !== null) {
         $target->setDistance($distance);
     }
     if ($health !== null) {
         $target->setHealth($health);
     }
     return $target;
 }
예제 #6
0
 /**
  * Store the mailing in database
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('mailing' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::action('TargetController@create')->withErrors($validator);
     } else {
         $target = new Target();
         $target->importCSV(Input::get('name'), Input::file('mailing'));
         return View::make('marketing.target.index')->with('success', true)->with('cont', $target->cont);
     }
 }
예제 #7
0
파일: Source.php 프로젝트: hippout/eco-test
 /**
  * Возвращает запросы на создание таблиц базы -цели
  * @param Target $target - целевая БД   
  */
 public function getTablesCreationQueries(Target $target)
 {
     $queriesSrc = $target->getSchema()->getMigrateToSql($this->getSchema(), $target->getConnect()->getDatabasePlatform());
     $tablesQueries = array();
     $indexesQueries = array();
     foreach ($queriesSrc as $query) {
         if (preg_match('/^CREATE TABLE ([a-z0-9_]*) .*/', $query, $matched) && in_array($matched[1], $this->exportingTables)) {
             $tablesQueries[] = $query;
         } elseif (preg_match('/^CREATE[ UNIQUE]* INDEX .* ON ([a-z0-9_]*) .*/', $query, $matched) && in_array($matched[1], $this->exportingTables)) {
             $indexesQueries[] = $query;
         }
     }
     return array_merge($tablesQueries, $indexesQueries);
 }
예제 #8
0
 /**
  * Store a newly created resource in storage.
  * POST /actions
  *
  * @return Response
  */
 public function store()
 {
     $response = new stdClass();
     $statusCode = 201;
     $in = Input::only('tid', 'created_at');
     $rules = array('tid' => 'required | integer');
     $vd = Validator::make($in, $rules);
     if ($vd->fails()) {
         $errs = $vd->messages();
         $statusCode = 400;
         $response = $errs->all();
     } else {
         $authId = Auth::user()->id;
         // 先檢查是否在 Target 有登記
         $uid = Target::where(array('id' => $in['tid'], 'uid' => $authId))->pluck('uid');
         // 取得使用者的教會
         $cid = UserChurch::where(array('uid' => $authId))->pluck('cid');
         if ($uid == $authId) {
             $in['uid'] = Auth::user()->id;
             $in['cid'] = $cid;
             $action = Action::create($in);
             if ($in['created_at']) {
                 $in['created_at'] = Carbon::createFromTimeStamp($in['created_at'], 'Asia/Taipei')->toDateTimeString();
                 $action->setCreatedAt($in['created_at']);
                 $action->save();
             }
         } else {
             $statusCode = 403;
         }
     }
     return Response::json($response, $statusCode);
 }
예제 #9
0
파일: Policy.php 프로젝트: galmi/xacml
 /**
  *  ---------------------------------------------------------------------------
  * |    Target       | Rule values |              Policy Value                 |
  *  ---------------------------------------------------------------------------
  * | “Match”         | Don’t care  | Specified by the rule-combining algorithm |
  * | “No-match”      | Don’t care  | “NotApplicable”                           |
  * | “Indeterminate” | See Table 7 | See Table 7                               |
  *  ---------------------------------------------------------------------------
  *
  * Table 7
  *  --------------------------------------------------------
  * | Combining algorithm Value | Policy set or policy Value |
  *  --------------------------------------------------------
  * | “NotApplicable”           | “NotApplicable”            |
  * | “Permit”                  | “Indeterminate{P}”         |
  * | “Deny”                    | “Indeterminate{D}”         |
  * | “Indeterminate”           | “Indeterminate{DP}”        |
  * | “Indeterminate{DP}”       | “Indeterminate{DP}”        |
  * | “Indeterminate{P}”        | “Indeterminate{P}”         |
  * | “Indeterminate{D}”        | “Indeterminate{D}”         |
  *  --------------------------------------------------------
  *
  * @inheritdoc
  */
 public function evaluate(Request $request)
 {
     $targetValue = null;
     $combiningAlgorithmDecision = null;
     $decision = Decision::NOT_APPLICABLE;
     $targetValue = $this->target->evaluate($request);
     if ($targetValue === Match::MATCH) {
         $decision = $this->getRuleCombiningAlgorithm()->evaluate($request, $this->getRules());
     } elseif ($targetValue === Match::INDETERMINATE) {
         switch ($this->getRuleCombiningAlgorithm()->evaluate($request, $this->getRules())) {
             case Decision::NOT_APPLICABLE:
                 $decision = Decision::NOT_APPLICABLE;
                 break;
             case Decision::PERMIT:
                 $decision = Decision::INDETERMINATE_P;
                 break;
             case Decision::DENY:
                 $decision = Decision::INDETERMINATE_D;
                 break;
             case Decision::INDETERMINATE_D_P:
                 $decision = Decision::INDETERMINATE_D_P;
                 break;
             case Decision::INDETERMINATE_P:
                 $decision = Decision::INDETERMINATE_P;
                 break;
             case Decision::INDETERMINATE_D:
                 $decision = Decision::INDETERMINATE_D;
                 break;
             default:
                 $decision = Decision::INDETERMINATE_D_P;
         }
     }
     return $decision;
 }
예제 #10
0
 public function testMainTrueUnlessDoesntPerformTasks()
 {
     $this->project->setProperty('unlessProperty', 'someValue');
     $this->target->setUnless('unlessProperty');
     $task = $this->getMock('Task');
     $task->expects($this->never())->method('perform');
     $this->target->addTask($task);
     $this->target->main();
 }
예제 #11
0
 public function getHome()
 {
     $key = cacheKey('home', Session::get('period'));
     if (Cache::has($key)) {
         $data = Cache::get($key);
     } else {
         $max = 0;
         $min = 1000000;
         $data = array('accounts' => array(), 'budgets' => array(), 'targets' => array());
         // we need this list:
         $accounts = Auth::user()->accounts()->get();
         foreach ($accounts as $a) {
             $account = array('id' => intval($a->id), 'name' => Crypt::decrypt($a->name), 'currentbalance' => $a->balance());
             $account['header'] = $account['currentbalance'] < 0 ? array('style' => 'color:red;', 'class' => 'tt', 'title' => $account['name'] . ' has a balance below zero. Try to fix this.') : array();
             $min = $account['currentbalance'] < $min ? $account['currentbalance'] : $min;
             $max = $account['currentbalance'] > $max ? $account['currentbalance'] : $max;
             $data['accounts'][] = $account;
         }
         $min = $min > 0 ? 0 : $min;
         $max = $max < 0 ? 0 : $max;
         $min = floor($min / 1000) * 1000;
         $max = ceil($max / 1000) * 1000;
         $sum = 0;
         foreach ($data['accounts'] as $index => $account) {
             $sum += $account['currentbalance'];
         }
         $data['acc_data']['sum'] = $sum;
         // now everything for budgets:
         $data['budgets'] = Budget::getHomeOverview();
         // some extra budget data:
         $monthlyAmount = Setting::getSetting('monthlyAmount', Session::get('period')->format('Y-m-') . '01');
         if (is_null($monthlyAmount)) {
             $monthlyAmount = intval(Setting::getSetting('defaultAmount'));
         }
         $data['budget_data']['amount'] = $monthlyAmount;
         $data['budget_data']['spent_outside'] = floatval(Auth::user()->transactions()->where('amount', '<', 0)->whereNull('budget_id')->where(DB::Raw('DATE_FORMAT(`date`,"%m-%Y")'), '=', Session::get('period')->format('m-Y'))->sum('amount')) * -1;
         // targets, cant make it better im afraid.
         $data['targets'] = Target::getHomeOverview();
         Cache::put($key, $data, 2440);
     }
     // flash some warnings:
     if (Auth::user()->transactions()->count() == 0) {
         Session::flash('warning', 'There are no transactions saved yet. Create some to make this overview less boring (Create &rarr; New transaction).');
     }
     if (count($data['budgets']) == 0) {
         Session::flash('warning', 'You don\'t have any budgets defined.');
     }
     if (count($data['accounts']) == 0) {
         Session::flash('warning', 'You do not have any accounts added. You should do this first (Create &rarr; New account)');
     }
     if (Holmes::isMobile()) {
         return View::make('mobile.home.home')->with('data', $data);
     } else {
         return View::make('home.home')->with('data', $data);
     }
 }
 public function __construct($dayOfWeek = null, $startHour = null, $startMinute = null, $endHour = null, $endMinute = null, $bidMultiplier = null, $TargetType = null)
 {
     parent::__construct();
     $this->dayOfWeek = $dayOfWeek;
     $this->startHour = $startHour;
     $this->startMinute = $startMinute;
     $this->endHour = $endHour;
     $this->endMinute = $endMinute;
     $this->bidMultiplier = $bidMultiplier;
     $this->TargetType = $TargetType;
 }
예제 #13
0
파일: queues.php 프로젝트: rasouza/Projeter
 public function fire($job, $data)
 {
     $file = Config::get('projeter.upload_path') . $data['file'];
     Log::info("Starting to add {$data['target']} to database (File: {$file})");
     $target = new Target();
     $target->name = $data['target'];
     $target->save();
     $reader = new \EasyCSV\Reader($file);
     // There must be a Email field in CSV file
     /*if(!in_array('Email', $reader->getHeaders() ))
     		throw new Exception("Email field not found", 1);*/
     while ($row = $reader->getRow()) {
         Log::info("Adding {$row['Email']} to the target {$data['target']}");
         $mailing = new Mailing();
         $mailing->target()->associate($target);
         $mailing->email = $row['Email'];
         $mailing->save();
     }
     Log::info("Mailing list {$target->name} added to database");
     $job->delete();
 }
예제 #14
0
 /**
  * A basic functional test example.
  *
  * @data void
  */
 public function testBasicExample()
 {
     $target = new Target();
     $target->importCSV('shipping.csv');
 }
예제 #15
0
 public function doOldImport()
 {
     DB::delete('DELETE FROM `cache`');
     // delete old data:
     foreach (Auth::user()->accounts()->get() as $acc) {
         $acc->delete();
     }
     foreach (Auth::user()->budgets()->get() as $b) {
         $b->delete();
     }
     foreach (Auth::user()->categories()->get() as $b) {
         $b->delete();
     }
     foreach (Auth::user()->beneficiaries()->get() as $b) {
         $b->delete();
     }
     foreach (Icon::get() as $icon) {
         $icon->delete();
     }
     $data = file_get_contents('http://commondatastorage.googleapis.com/nder/import.json');
     $json = json_decode($data);
     $map = array();
     $map['accounts'] = array();
     $map['icons'] = array();
     // all accounts:
     foreach ($json->accounts as $account) {
         $newAccount = new Account();
         $newAccount->name = Crypt::encrypt($account->name);
         $newAccount->balance = floatval($account->balance);
         $newAccount->fireflyuser_id = Auth::user()->id;
         $newAccount->date = $account->date;
         $newAccount->save();
         $map['accounts'][$account->id] = $newAccount->id;
     }
     // all icons:
     foreach ($json->icons as $icon) {
         $newIcon = new Icon();
         $newIcon->file = $icon->file;
         $newIcon->save();
         $map['icons'][intval($icon->id)] = $newIcon->id;
     }
     // all beneficiaries:
     foreach ($json->beneficiaries as $ben) {
         $nb = new Beneficiary();
         $nb->fireflyuser_id = Auth::user()->id;
         $nb->name = Crypt::encrypt($ben->name);
         $nb->save();
         $map['beneficiaries'][$ben->id] = $nb->id;
     }
     // all budgets
     foreach ($json->budgets as $bd) {
         $nbg = new Budget();
         $nbg->fireflyuser_id = Auth::user()->id;
         $nbg->name = Crypt::encrypt($bd->name);
         $nbg->date = $bd->date;
         $nbg->amount = floatval($bd->amount);
         $nbg->save();
         $map['budgets'][$bd->id] = $nbg->id;
     }
     // all categories:
     foreach ($json->categories as $c) {
         $nc = new Category();
         $nc->fireflyuser_id = Auth::user()->id;
         $nc->icon_id = intval($map['icons'][intval($c->icon_id)]);
         $nc->name = Crypt::encrypt($c->name);
         $nc->showtrend = intval($c->showtrend);
         $nc->save();
         $map['categories'][$c->id] = $nc->id;
     }
     foreach ($json->targets as $t) {
         $nt = new Target();
         $nt->fireflyuser_id = Auth::user()->id;
         $nt->account_id = $map['accounts'][$t->account_id];
         $nt->description = Crypt::encrypt($t->description);
         $nt->amount = floatval($t->amount);
         $nt->duedate = $t->duedate;
         $nt->startdate = $t->startdate;
         $nt->save();
         $map['targets'][$t->id] = $nt->id;
     }
     foreach ($json->transactions as $t) {
         $nt = new Transaction();
         $nt->fireflyuser_id = Auth::user()->id;
         $nt->account_id = $map['accounts'][$t->account_id];
         $nt->budget_id = is_null($t->budget_id) ? NULL : intval($map['budgets'][$t->budget_id]);
         $nt->category_id = is_null($t->category_id) ? NULL : $map['categories'][$t->category_id];
         $nt->beneficiary_id = is_null($t->beneficiary_id) ? NULL : $map['beneficiaries'][$t->beneficiary_id];
         $nt->description = Crypt::encrypt($t->description);
         $nt->amount = floatval($t->amount);
         $nt->date = $t->date;
         $nt->onetime = intval($t->onetime);
         $nt->save();
         $map['transactions'][$t->id] = $nt->id;
     }
     foreach ($json->transfers as $t) {
         $nt = new Transfer();
         $nt->fireflyuser_id = Auth::user()->id;
         $nt->account_from = $map['accounts'][$t->account_from];
         $nt->account_to = $map['accounts'][$t->account_to];
         $nt->category_id = is_null($t->category_id) ? NULL : $map['categories'][$t->category_id];
         $nt->budget_id = is_null($t->budget_id) ? NULL : intval($map['budgets'][$t->budget_id]);
         $nt->target_id = is_null($t->target_id) ? NULL : intval($map['targets'][$t->target_id]);
         $nt->description = Crypt::encrypt($t->description);
         $nt->amount = floatval($t->amount);
         $nt->date = $t->date;
         $nt->save();
         $map['targets'][$t->id] = $nt->id;
     }
     //
     //var_dump($data);
     // create everything from this file.
     // we map the old id's to the new one to save problems.
     return 'Old data successfully imported.';
 }
예제 #16
0
 /**
  * Reviews a file potentially modifying it, and returning issues
  * 
  * @param type $fileResource
  * @param type $options 
  * @return array[CodeIssue] an array of issues found
  */
 function reviewTarget(Target $target, $options = null)
 {
     if (!$this->isSupported($target->getType())) {
         return false;
     }
     return $this->reviewFile($target->getPath(), $options);
 }
예제 #17
0
 /**
  * Tests Target::unlink
  */
 public function testUnlinkSuccess()
 {
     $path = sys_get_temp_dir() . '/foo';
     $filename = 'foo.txt';
     $target = new Target($path, $filename);
     $target->setupPath();
     // create the file
     file_put_contents($target->getPathname(), 'content');
     $target->unlink();
     rmdir($target->getPath());
     $this->assertFalse(file_exists($target->getPathname()));
     $this->assertFalse(is_dir($target->getPath()));
 }
예제 #18
0
 /**
  * Adds or replaces a target in the project
  * @param string $targetName
  * @param Target $target
  */
 public function addOrReplaceTarget($targetName, &$target)
 {
     $this->log("  +Target: {$targetName}", Project::MSG_DEBUG);
     $target->setProject($this);
     $this->targets[$targetName] = $target;
     $ctx = $this->getReference("phing.parsing.context");
     $current = $ctx->getCurrentTargets();
     $current[$targetName] = $target;
 }
 public function __construct($dayOfWeek = NULL, $startHour = NULL, $startMinute = NULL, $endHour = NULL, $endMinute = NULL, $bidMultiplier = NULL, $TargetType = NULL)
 {
     if (get_parent_class('AdScheduleTarget')) {
         parent::__construct();
     }
     $this->dayOfWeek = $dayOfWeek;
     $this->startHour = $startHour;
     $this->startMinute = $startMinute;
     $this->endHour = $endHour;
     $this->endMinute = $endMinute;
     $this->bidMultiplier = $bidMultiplier;
     $this->TargetType = $TargetType;
 }
예제 #20
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Target $value A Target object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Target $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
예제 #21
0
 public function newTarget()
 {
     $target = new Target();
     $target->amount = floatval(Input::get('amount'));
     $target->description = Input::get('description');
     $target->fireflyuser_id = Auth::user()->id;
     $target->duedate = Input::get('duedate');
     $target->startdate = Input::get('startdate');
     $target->closed = 0;
     if (!is_null(Input::get('account'))) {
         $account = Auth::user()->accounts()->find(Input::get('account'));
         if (!is_null($account)) {
             $target->account_id = $account->id;
         }
     }
     $validator = Validator::make($target->toArray(), Target::$rules);
     $target->description = Crypt::encrypt($target->description);
     if ($validator->fails()) {
         return Redirect::to('/home/target/add')->withErrors($validator)->withInput();
     } else {
         $target->save();
         return Redirect::to('/home');
     }
 }
예제 #22
0
 public function doSomething(Target $target)
 {
     return $target->request(new Adaptee());
 }
예제 #23
0
 /**
  * Initializes a new instance of the class.
  * @param array $config Name-value pairs that will be used to initialize the object properties.
  */
 public function __construct($config = [])
 {
     $this->client = \Yii::createObject(Client::class);
     parent::__construct($config);
 }
예제 #24
0
파일: demo.php 프로젝트: imikay/igetui
function pushMessageToList()
{
    putenv("needDetails=true");
    $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
    //消息模版:
    // 1.TransmissionTemplate:透传功能模板
    // 2.LinkTemplate:通知打开链接功能模板
    // 3.NotificationTemplate:通知透传功能模板
    // 4.NotyPopLoadTemplate:通知弹框下载功能模板
    //$template = IGtNotyPopLoadTemplateDemo();
    $template = IGtLinkTemplateDemo();
    //$template = IGtNotificationTemplateDemo();
    //$template = IGtTransmissionTemplateDemo();
    //个推信息体
    $message = new SingleMessage();
    $message->set_isOffline(true);
    //是否离线
    $message->set_offlineExpireTime(3600 * 12 * 1000);
    //离线时间
    $message->set_data($template);
    //设置推送消息类型
    $contentId = $igt->getContentId($message);
    //接收方1
    $target1 = new Target();
    $target1->set_appId(APPID);
    $target1->set_clientId(CID);
    $targetList[] = $target1;
    $rep = $igt->pushMessageToList($contentId, $targetList);
    var_dump($rep);
    echo "<br><br>";
}
예제 #25
0
 /**
  * Remove the specified resource from storage.
  * DELETE /targets/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $response = new stdClass();
     $statusCode = 200;
     $authId = Auth::user()->id;
     $target = Target::find($id);
     if ($target && $target->uid == $authId) {
         // 紀錄在 busted
         Busted::create($target->toArray());
         $target->forceDelete();
     } else {
         $statusCode = 403;
     }
     return Response::json($response, $statusCode);
 }
 /**
  * update a target by his values
  * @param $id The target's id
  * @param array $values
  * @return null|Target
  */
 public function updateTargetFromValues($id, array $values)
 {
     list($this->last_result, $this->last_error) = $this->rest_client->put($this->path . '/' . $id, $values);
     $this->erreur = $this->getError($this->last_result, $this->last_error);
     if (isset($this->erreur)) {
         return null;
     }
     if (!Target::isJsonValid($this->last_result)) {
         $this->erreur = $this->jsonErrorMessage();
         return null;
     }
     return new Target($this->last_result);
 }
예제 #27
0
 public function draw(&$canvas, $color = 657930, $exceptions = [])
 {
     $color = is_null($this->color) ? $color : $this->color;
     $half = $this->width / 2;
     for ($pixelX = $this->center->x - $half; $pixelX <= $this->center->x + $half; $pixelX++) {
         imagesetpixel($canvas, $pixelX, $this->center->y, $color);
     }
     if (!is_null($this->childTarget)) {
         $this->childTarget->draw($canvas);
     }
 }
예제 #28
0
 /**
  * Creates the ExpatParser, sets root handler and kick off parsing
  * process.
  *
  * @throws BuildException if there is any kind of execption during
  *                        the parsing process
  */
 protected function parse()
 {
     try {
         // get parse context
         $ctx = $this->project->getReference("phing.parsing.context");
         if (null == $ctx) {
             // make a new context and register it with project
             $ctx = new PhingXMLContext($this->project);
             $this->project->addReference("phing.parsing.context", $ctx);
         }
         //record this parse with context
         $ctx->addImport($this->buildFile);
         if (count($ctx->getImportStack()) > 1) {
             $currentImplicit = $ctx->getImplicitTarget();
             $currentTargets = $ctx->getCurrentTargets();
             $newCurrent = new Target();
             $newCurrent->setProject($this->project);
             $newCurrent->setName('');
             $ctx->setCurrentTargets(array());
             $ctx->setImplicitTarget($newCurrent);
             // this is an imported file
             // modify project tag parse behavior
             $this->setIgnoreProjectTag(true);
             $this->_parse($ctx);
             $newCurrent->main();
             $ctx->setImplicitTarget($currentImplicit);
             $ctx->setCurrentTargets($currentTargets);
         } else {
             $ctx->setCurrentTargets(array());
             $this->_parse($ctx);
             $ctx->getImplicitTarget()->main();
         }
     } catch (Exception $exc) {
         //throw new BuildException("Error reading project file", $exc);
         throw $exc;
     }
 }
        $actionRule = $user;
        break;
    case 2:
        $actionRule = $attacker;
        break;
}
$enforcer = new Enforcer();
$decider = new Decider();
$enforcer->setDecider($decider);
// Create some Matches
//Action requested by the user
$match1 = new Match('StringEqual', 'property1', 'TestMatch1', $action);
//Action allowed by what policy states that group can do
$match2 = new Match('StringEqual', 'property1', 'TestMatch2', $actionRule);
// Create a Target container for our Matches
$target = new Target();
$target->addMatches(array($match1, $match2));
// Make a new Rule and add the Target to it
$rule1 = new Rule();
$rule1->setTarget($target)->setId('TestRule')->setEffect('Permit')->setDescription('Test to see if there is an attribute on the subject' . 'that exactly matches the word "test"')->setAlgorithm(new DenyOverrides());
// Make two new policies and add the Rule to it (with our Match)
$policy1 = new Policy();
$policy1->setAlgorithm('AllowOverrides')->setId('Policy1')->addRule($rule1);
$policy2 = new Policy();
$policy2->setAlgorithm('DenyOverrides')->setId('Policy2')->addRule($rule1);
// Create the subject with its own Attribute
$subject = new Subject();
$subject->addAttribute(new Attribute('property1', $actionRule));
// Link the Policies to the Resource
$resource = new Resource();
$resource->addPolicy($policy1)->addPolicy($policy2);
예제 #30
0
 public function __construct($rootDir)
 {
     parent::__construct($rootDir, trim(file_get_contents($rootDir . DIRECTORY_SEPARATOR . 'target')));
 }