public function hasRole($user, $role)
 {
     if (!is_array($role)) {
         $role = array($role);
     }
     $roles = Role::whereIn('id', explode(',', $role))->get();
     if (count($roles) != cont($role)) {
         return response('Grupos de Permissões inválidos', 422);
     }
     foreach ($permission as $value) {
     }
 }
Example #2
0
function main()
{
    $arr = array();
    var_dump($arr instanceof \HH\Traversable);
    var_dump($arr instanceof \HH\KeyedTraversable);
    var_dump($arr instanceof \HH\Container);
    var_dump($arr instanceof \HH\KeyedContainer);
    var_dump($arr instanceof Indexish);
    var_dump($arr instanceof IFoo);
    trav($arr);
    ktrav($arr);
    cont($arr);
    kcont($arr);
    ind($arr);
    ifoo($arr);
}
	/**
	 * Groups the set by $groupField and returns the parent of each group whose class
	 * is $groupClassName. If $collapse is true, the group will be collapsed up until an ancestor with the
	 * given class is found.
	 * @param string $groupField The field to group by.
	 * @param string $groupClassName Classname.
	 * @param string $sortParents SORT clause to insert into the parents SQL.
	 * @param string $parentField Parent field.
	 * @param boolean $collapse Collapse up until an ancestor with the given class is found.
	 * @param string $requiredParents Required parents
	 * @return DataObjectSet
	 */
	public function groupWithParents($groupField, $groupClassName, $sortParents = null, $parentField = 'ID', $collapse = false, $requiredParents = null) {
		// Each item in this DataObjectSet is grouped into a multidimensional array
		// indexed by it's parent. The parent IDs are later used to find the parents
		// that make up the returned set.
		$groupedSet = array();

		// Array to store the subgroups matching the requirements
		$resultsArray = array();

		// Put this item into the array indexed by $groupField.
		// the keys are later used to retrieve the top-level records
		foreach( $this->items as $item ) {
			$groupedSet[$item->$groupField][] = $item;
		}

		$parentSet = null;

		// retrieve parents for this set

		// TODO How will we collapse the hierarchy to bridge the gap?

		// if collapse is specified, then find the most direct ancestor of type
		// $groupClassName
		if($collapse) {
			// The most direct ancestors with the type $groupClassName
			$parentSet = array();

			// get direct parents
			$parents = DataObject::get( 'SiteTree', "`SiteTree`.`$parentField` IN( " . implode( ",", array_keys( $groupedSet ) ) . ")", $sortParents );	
			
			// for each of these parents...
			foreach($parents as $parent) {
				// store the old parent ID. This is required to change the grouped items
				// in the $groupSet array
				$oldParentID = $parent->ID;

				// get the parental stack
				$parentObjects= $parent->parentStack();
				$parentStack = array();

				foreach( $parentObjects as $parentObj )
					$parentStack[] = $parentObj->ID;

				// is some particular IDs are required, then get the intersection
				if($requiredParents && count($requiredParents)) {
					$parentStack = array_intersect($requiredParents, $parentStack);
				}

				$newParent = null;

				// If there are no parents, the group can be omitted
				if(empty($parentStack)) {
					$newParent = new DataObjectSet();
				} else {
				 	$newParent = DataObject::get_one( $groupClassName, "`SiteTree`.`$parentField` IN( " . implode( ",", $parentStack ) . ")" );		
				}
			
				// change each of the descendant's association from the old parent to
				// the new parent. This effectively collapses the hierarchy
				foreach( $groupedSet[$oldParentID] as $descendant ) {
					$groupedSet[$newParent->ID][] = $descendant;
				}

				// Add the most direct ancestor of type $groupClassName
				$parentSet[] = $newParent;
			}
		// otherwise get the parents of these items
		} else {

			$requiredIDs = array_keys( $groupedSet );
			
			if( $requiredParents && cont($requiredParents)) {
				$requiredIDs = array_intersect($requiredParents, $requiredIDs);
			}
				
			if(empty($requiredIDs)) {
				$parentSet = new DataObjectSet();
			} else {
				$parentSet = DataObject::get( $groupClassName, "`$groupClassName`.`$parentField` IN( " . implode( ",", $requiredIDs ) . ")", $sortParents );	
			}
			
			$parentSet = $parentSet->toArray();
		}
		
		foreach($parentSet as $parent) {
			$resultsArray[] = $parent->customise(array(
				"GroupItems" => new DataObjectSet($groupedSet[$parent->$parentField])
			));
		}
			
		return new DataObjectSet($resultsArray);
	}
Example #4
0
function disconnect()
{
    self::$cont = null;
}
Example #5
0
/**
 * Return a UserSet of participants in the debate tree for the given issue nodeid
 *
 * @param nodeid the nodeid of the Issue node to get the tree for.
 * @param style, the style of node to return - how much data it has (defaults to 'mini' can also be 'long' or 'short')
 * @return UserSet or Error.
 *
 * @uses getDebate
 */
function getDebateParticipants($nodeid, $style = 'mini')
{
    $consSet = getDebate($nodeid, $style);
    $cons = $consSet->connections;
    $count = cont($cons);
    $userSet = new UserSet();
    $userCheck = array();
    for ($i = 0; $i < $count; $i++) {
        $next = $cons[$i];
        $from = $next->from;
        $to = $next->to;
        if (!in_array($from->users[0]->userid, $userCheck)) {
            array_push($userCheck, $from->users[0]->userid);
            $userSet->add($from->users[0]);
        }
        if (!in_array($to->users[0]->userid, $userCheck)) {
            array_push($userCheck, $to->users[0]->userid);
            $userSet->add($to->users[0]);
        }
        if (!in_array($next->userid, $userCheck)) {
            array_push($userCheck, $next->users[0]->userid);
            $userSet->add($next->users[0]);
        }
    }
    return $userSet;
}
Example #6
0
function sub_insert($vote_sub, $id = '0')
{
    global $db;
    unset($vote_sub['action']);
    unset($vote_sub['check']);
    if ($id != '0' || empty($id)) {
        $uid = $id;
    }
    if ($uid == '0' || empty($uid)) {
        $uid = $vote_sub['uid'];
    }
    unset($vote_sub['uid']);
    unset($vote_sub['htotal_guid_1']);
    $ip = $_SERVER["REMOTE_ADDR"];
    $sub_time = DATE('Y-m-d H:i:s');
    foreach ($vote_sub as $k => $v) {
        $sql = "select content from  vote_content where  vid = '{$k}'";
        $content = $db->getOne($sql);
        $str = cont($content, $v);
        if (!empty($str)) {
            $sql = "insert into vote_sub (uid,ip,sub_time,vid,vote_result) values ('{$uid}','{$ip}','{$sub_time}','{$k}','{$str}')";
            $db->query($sql);
        }
        $value = "";
        $optionk = "";
        $optionv = "";
    }
    result_insert($vote_sub);
    foreach ($vote_sub as $k => $v) {
        $str1 .= $k . '.';
        if (is_array($v)) {
            foreach ($v as $kk => $vv) {
                $str1 .= $vv . ' ';
            }
        }
        $str1 .= ',';
    }
    //echo $str1 ;
    $str = UrlEncode($str1);
    header("Location: index.php?n=service&h=qixi&action=result&uid='.{$uid}.'&sub='.{$str}");
    //results_show($vote_sub);
}
Example #7
0
 public function nieposiadanerzeczy()
 {
     $ekwipunek = $this->wiedzmin->getekwipunek();
     for ($i = 0; $i < count($this->zaznaczone); $i++) {
         for ($j = 0; $j < cont($ekwipunek); $j++) {
             if ($ekwipunek[$j][nazwa] == $this->zaznaczone[$i][nazwa]) {
                 $this->{$posiadane}[] = $this->zaznaczone[$i];
             }
         }
     }
 }
Example #8
0
 private function setJoinConditions($tableFrom)
 {
     $tableFromRow = $this->getFKConstraint('REFERENCED_TABLE_NAME', $tableFrom);
     if ($tableFromRow == false) {
         return;
     }
     if (cont($tableFromRow) > 1) {
         //now determine which join table is relevant to our mapping.
         //with the addition of users_tags, we are in a sticky situation:
         //we're not interested in joining users on tags for a request like:
         //users/1/posts/tags
         //nor are we interested in joining posts on tags for a request like:
         //posts/1/users/tags
     }
 }
Example #9
0
 public function potrzebnezloto()
 {
     foreach ($this->getpost('zaznaczone') as $zaznaczone) {
         for ($i = 0; $i < cont($this->wynik); $i++) {
             if ($this->wynik[$i]['id'] == $zaznaczone) {
                 $this->zaznaczone[] = $this->wynik[$i];
                 $zloto += $this->wynik[$i][cena];
             }
         }
     }
     return $zloto;
 }