public function channelGroupPermAssign($cgid, $permid, $permvalue)
  {
    $permident = (is_numeric($permid)) ? "permid" : "permsid";

    $this->execute("channelgroupaddperm", array("cgid" => $cgid, $permident => $permid, "permvalue" => $permvalue));
  }

public function channelGroupPermAssign ( $ cgid , $ permid , $ permvalue ) { $ permident = ( is_numeric ( $ permid ) ) ? "permid" : "permsid" ; $ this -> execute ( "channelgroupaddperm" , array ( "cgid" => $ cgid , $ permident => $ permid , "permvalue" => $ permvalue ) ) ; }

Adds a set of specified permissions to the channel group specified. Multiple permissions
can be added by providing the two parameters of each permission in separate arrays.

@param  integer $cgid
@param  integer $permid
@param  integer $permvalue
@return void

Adds a set of specified permissions to the channel group specified . Multiple permissions can be added by providing the two parameters of each permission in separate arrays .


public function permReset()
  {
    $token = $this->request("permreset")->toList();

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyTokencreated", $this, $token["token"]);

    return $token["token"];
  }

public function permReset ( ) { $ token = $ this -> request ( "permreset" ) -> toList ( ) ; \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Signal :: getInstance ( ) -> emit ( "notifyTokencreated" , $ this , $ token [ "token" ] ) ; return $ token [ "token" ] ; }

Restores the default permission settings on the virtual server and returns a new initial
administrator privilege key.

@return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String

Restores the default permission settings on the virtual server and returns a new initial administrator privilege key .


public function iconUpload($data)
  {
    $crc = crc32($data);
    $size = strlen($data);

    $upload = $this->transferInitUpload(rand(0x0000, 0xFFFF), 0, "/icon_" . $crc, $size);
    $transfer = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::factory("filetransfer://" . $upload["host"] . ":" . $upload["port"]);

    $transfer->upload($upload["ftkey"], $upload["seekpos"], $data);

    return $crc;
  }

public function iconUpload ( $ data ) { $ crc = crc32 ( $ data ) ; $ size = strlen ( $ data ) ; $ upload = $ this -> transferInitUpload ( rand ( 0x0000 , 0xFFFF ) , 0 , "/icon_" . $ crc , $ size ) ; $ transfer = \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ TeamSpeak3 :: factory ( "filetransfer://" . $ upload [ "host" ] . ":" . $ upload [ "port" ] ) ; $ transfer -> upload ( $ upload [ "ftkey" ] , $ upload [ "seekpos" ] , $ data ) ; return $ crc ; }

Uploads a given icon file content to the server and returns the ID of the icon.

@param  string $data
@return integer

Uploads a given icon file content to the server and returns the ID of the icon .


public function snapshotCreate($mode = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SNAPSHOT_STRING)
  {
    $snapshot = $this->request("serversnapshotcreate")->toString(FALSE);

    switch($mode)
    {
      case \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SNAPSHOT_BASE64:
        return $snapshot->toBase64();
        break;

      case \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SNAPSHOT_HEXDEC:
        return $snapshot->toHex();
        break;

      default:
        return (string) $snapshot;
        break;
    }
  }

public function snapshotCreate ( $ mode = \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ TeamSpeak3 :: SNAPSHOT_STRING ) { $ snapshot = $ this -> request ( "serversnapshotcreate" ) -> toString ( FALSE ) ; switch ( $ mode ) { case \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ TeamSpeak3 :: SNAPSHOT_BASE64 : return $ snapshot -> toBase64 ( ) ; break ; case \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ TeamSpeak3 :: SNAPSHOT_HEXDEC : return $ snapshot -> toHex ( ) ; break ; default : return ( string ) $ snapshot ; break ; } }

Creates and returns snapshot data for the selected virtual server.

@param  string $mode
@return string

Creates and returns snapshot data for the selected virtual server .


public function logView($limitcount = 30, $comparator = null, $timestamp = null)
  {
    return $this->execute("logview", array("limitcount" => $limitcount, "comparator" => $comparator, "timestamp" => $timestamp))->toArray();
  }

public function logView ( $ limitcount = 30 , $ comparator = null , $ timestamp = null ) { return $ this -> execute ( "logview" , array ( "limitcount" => $ limitcount , "comparator" => $ comparator , "timestamp" => $ timestamp ) ) -> toArray ( ) ; }

Returns a specified number of entries from the servers log.

@param  integer $limitcount
@param  string  $comparator
@param  string  $timestamp
@return array

Returns a specified number of entries from the servers log .


public function logAdd($logmsg, $loglevel = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::LOGLEVEL_INFO)
  {
    $this->execute("logadd", array("logmsg" => $logmsg, "loglevel" => $loglevel));
  }

public function logAdd ( $ logmsg , $ loglevel = \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ TeamSpeak3 :: LOGLEVEL_INFO ) { $ this -> execute ( "logadd" , array ( "logmsg" => $ logmsg , "loglevel" => $ loglevel ) ) ; }

Writes a custom entry into the virtual server log.

@param  string  $logmsg
@param  integer $loglevel
@return void

Writes a custom entry into the virtual server log .


protected static function sortClientList(Client $a, Client $b)
  {
    if(get_class($a) != get_class($b))
    {
      return 0;

      /* workaround for PHP bug #50688 */
      throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid parameter", 0x602);
    }

    if(!$a instanceof Client)
    {
      return 0;

      /* workaround for PHP bug #50688 */
      throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("convert error", 0x604);
    }

    if($a->getProperty("client_talk_power", 0) != $b->getProperty("client_talk_power", 0))
    {
      return ($a->getProperty("client_talk_power", 0) > $b->getProperty("client_talk_power", 0)) ? -1 : 1;
    }

    if($a->getProperty("client_is_talker", 0) != $b->getProperty("client_is_talker", 0))
    {
      return ($a->getProperty("client_is_talker", 0) > $b->getProperty("client_is_talker", 0)) ? -1 : 1;
    }

    return strcmp(strtolower($a["client_nickname"]), strtolower($b["client_nickname"]));
  }

protected
static
function
sortClientList
(
Client
$
a
,
Client
$
b
)
{
if
(
get_class
(
$
a
)
!=
get_class
(
$
b
)
)
{
return
0
;
/* workaround for PHP bug #50688 */
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid parameter"
,
0x602
)
;
}
if
(
!
$
a
instanceof
Client
)
{
return
0
;
/* workaround for PHP bug #50688 */
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"convert error"
,
0x604
)
;
}
if
(
$
a
->
getProperty
(
"client_talk_power"
,
0
)
!=
$
b
->
getProperty
(
"client_talk_power"
,
0
)
)
{
return
(
$
a
->
getProperty
(
"client_talk_power"
,
0
)
>
$
b
->
getProperty
(
"client_talk_power"
,
0
)
)
1
:
1
;
}
if
(
$
a
->
getProperty
(
"client_is_talker"
,
0
)
!=
$
b
->
getProperty
(
"client_is_talker"
,
0
)
)
{
return
(
$
a
->
getProperty
(
"client_is_talker"
,
0
)
>
$
b
->
getProperty
(
"client_is_talker"
,
0
)
)
1
:
1
;
}
return
strcmp
(
strtolower
(
$
a
[
"client_nickname"
]
)
,
strtolower
(
$
b
[
"client_nickname"
]
)
)
;
}

Internal callback funtion for sorting of client objects.

@param  Client $a
@param  Client $b
@return integer

Internal callback funtion for sorting of client objects .


protected static function sortGroupList(AbstractNode $a, AbstractNode $b)
  {
    if(get_class($a) != get_class($b))
    {
      return 0;

      /* workaround for PHP bug #50688 */
      throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid parameter", 0x602);
    }

    if(!$a instanceof Servergroup && !$a instanceof Channelgroup)
    {
      return 0;

      /* workaround for PHP bug #50688 */
      throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("convert error", 0x604);
    }

    if($a->getProperty("sortid", 0) != $b->getProperty("sortid", 0))
    {
      return ($a->getProperty("sortid", 0) < $b->getProperty("sortid", 0)) ? -1 : 1;
    }

    return ($a->getId() < $b->getId()) ? -1 : 1;
  }

protected
static
function
sortGroupList
(
AbstractNode
$
a
,
AbstractNode
$
b
)
{
if
(
get_class
(
$
a
)
!=
get_class
(
$
b
)
)
{
return
0
;
/* workaround for PHP bug #50688 */
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid parameter"
,
0x602
)
;
}
if
(
!
$
a
instanceof
Servergroup
&&
!
$
a
instanceof
Channelgroup
)
{
return
0
;
/* workaround for PHP bug #50688 */
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"convert error"
,
0x604
)
;
}
if
(
$
a
->
getProperty
(
"sortid"
,
0
)
!=
$
b
->
getProperty
(
"sortid"
,
0
)
)
{
return
(
$
a
->
getProperty
(
"sortid"
,
0
)
<
$
b
->
getProperty
(
"sortid"
,
0
)
)
1
:
1
;
}
return
(
$
a
->
getId
(
)
<
$
b
->
getId
(
)
)
1
:
1
;
}

Internal callback funtion for sorting of group objects.

@param  AbstractNode $a
@param  AbstractNode $b
@return integer

Internal callback funtion for sorting of group objects .


protected static function sortFileList(array $a, array $b)
  {
    if(!array_key_exists("src", $a) || !array_key_exists("src", $b))
    {
      return 0;

      throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid parameter", 0x602);
    }

    return strcmp(strtolower($a["src"]), strtolower($b["src"]));
  }

protected
static
function
sortFileList
(
array
$
a
,
array
$
b
)
{
if
(
!
array_key_exists
(
"src"
,
$
a
)
||
!
array_key_exists
(
"src"
,
$
b
)
)
{
return
0
;
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid parameter"
,
0x602
)
;
}
return
strcmp
(
strtolower
(
$
a
[
"src"
]
)
,
strtolower
(
$
b
[
"src"
]
)
)
;
}

Internal callback funtion for sorting of file list items.

@param  array $a
@param  array $b
@return integer

Internal callback funtion for sorting of file list items .


public function copy($name = null, $tsgid = 0, $type = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_DBTYPE_REGULAR)
  {
    return $this->getParent()->serverGroupCopy($this->getId(), $name, $tsgid, $type);
  }

public function copy ( $ name = null , $ tsgid = 0 , $ type = \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ TeamSpeak3 :: GROUP_DBTYPE_REGULAR ) { return $ this -> getParent ( ) -> serverGroupCopy ( $ this -> getId ( ) , $ name , $ tsgid , $ type ) ; }

Creates a copy of the server group and returns the new groups ID.

@param  string  $name
@param  integer $tsgid
@param  integer $type
@return integer

Creates a copy of the server group and returns the new groups ID .


public function iconGetName($key)
  {
    $iconid = ($this[$key] < 0) ? (pow(2, 32))-($this[$key]*-1) : $this[$key];

    return new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String("/icon_" . $iconid);
  }

public function iconGetName ( $ key ) { $ iconid = ( $ this [ $ key ] < 0 ) ? ( pow ( 2 , 32 ) ) - ( $ this [ $ key ] * - 1 ) : $ this [ $ key ] ; return new \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ String ( "/icon_" . $ iconid ) ; }

Returns the internal path of the node icon.

@return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String

Returns the internal path of the node icon .


public function getClass($prefix = "ts3_")
  {
    if($this instanceof Channel && $this->isSpacer())
    {
      return $prefix . "spacer";
    }
    elseif($this instanceof Client && $this["client_type"])
    {
      return $prefix . "query";
    }

    return $prefix . \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String::factory(get_class($this))->section("_", 2)->toLower();
  }

public function getClass ( $ prefix = "ts3_" ) { if ( $ this instanceof Channel && $ this -> isSpacer ( ) ) { return $ prefix . "spacer" ; } elseif ( $ this instanceof Client && $ this [ "client_type" ] ) { return $ prefix . "query" ; } return $ prefix . \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ String :: factory ( get_class ( $ this ) ) -> section ( "_" , 2 ) -> toLower ( ) ; }

Returns a possible classname for the node which can be used as a HTML property.

@return string

Returns a possible classname for the node which can be used as a HTML property .


public function getViewer(ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Viewer\ViewerInterface $viewer)
  {
    $html = $viewer->fetchObject($this);

    $iterator = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST);

    foreach($iterator as $node)
    {
      $siblings = array();

      for($level = 0; $level < $iterator->getDepth(); $level++)
      {
        $siblings[] = ($iterator->getSubIterator($level)->hasNext()) ? 1 : 0;
      }

      $siblings[] = (!$iterator->getSubIterator($level)->hasNext()) ? 1 : 0;

      $html .= $viewer->fetchObject($node, $siblings);
    }

    return $html;
  }

public function getViewer ( ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Viewer \ ViewerInterface $ viewer ) { $ html = $ viewer -> fetchObject ( $ this ) ; $ iterator = new RecursiveIteratorIterator ( $ this , RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ iterator as $ node ) { $ siblings = array ( ) ; for ( $ level = 0 ; $ level < $ iterator -> getDepth ( ) ; $ level ++ ) { $ siblings [ ] = ( $ iterator -> getSubIterator ( $ level ) -> hasNext ( ) ) ? 1 : 0 ; } $ siblings [ ] = ( ! $ iterator -> getSubIterator ( $ level ) -> hasNext ( ) ) ? 1 : 0 ; $ html .= $ viewer -> fetchObject ( $ node , $ siblings ) ; } return $ html ; }

Returns the HTML code to display a TeamSpeak 3 viewer.

@param  ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Viewer\ViewerInterface $viewer
@return string

Returns the HTML code to display a TeamSpeak 3 viewer .


protected function filterList(array $nodes = array(), array $rules = array())
  {
    if(!empty($rules))
    {
      foreach($nodes as $node)
      {
        if(!$node instanceof AbstractNode) continue;

        $props = $node->getInfo(FALSE);
        $props = array_intersect_key($props, $rules);
        $match = TRUE;

        foreach($props as $key => $val)
        {
          if($val instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String)
          {
            $match = $val->contains($rules[$key], TRUE);
          }
          else
          {
            $match = $val == $rules[$key];
          }

          if($match === FALSE)
          {
            unset($nodes[$node->getId()]);
          }
        }
      }
    }

    return $nodes;
  }

protected function filterList ( array $ nodes = array ( ) , array $ rules = array ( ) ) { if ( ! empty ( $ rules ) ) { foreach ( $ nodes as $ node ) { if ( ! $ node instanceof AbstractNode ) continue ; $ props = $ node -> getInfo ( FALSE ) ; $ props = array_intersect_key ( $ props , $ rules ) ; $ match = TRUE ; foreach ( $ props as $ key => $ val ) { if ( $ val instanceof \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ String ) { $ match = $ val -> contains ( $ rules [ $ key ] , TRUE ) ; } else { $ match = $ val == $ rules [ $ key ] ; } if ( $ match === FALSE ) { unset ( $ nodes [ $ node -> getId ( ) ] ) ; } } } } return $ nodes ; }

Filters given node list array using specified filter rules.

@param  array $nodes
@param  array $rules
@return array

Filters given node list array using specified filter rules .


private function writeFile(string $filename, string $content)
    {
        $directory = \dirname($filename);
        if (!\is_writable($directory)) {
            throw new \RuntimeException(\sprintf('Cache directory "%s" is not writable.', $directory));
        }

        $tmpFile = \tempnam($directory, \basename($filename));

        if (false === @\file_put_contents($tmpFile, $content)) {
            throw new \RuntimeException(\sprintf('Could not write file "%s".', $tmpFile));
        }
        if (!@\rename($tmpFile, $filename)) {
            throw new \RuntimeException(\sprintf('Could not write file "%s".', $filename));
        }
        @\chmod($filename, 0666 & ~\umask());
    }

private
function
writeFile
(
string
$
filename
,
string
$
content
)
{
$
directory
=
\
dirname
(
$
filename
)
;
if
(
!
\
is_writable
(
$
directory
)
)
{
throw
new
\
RuntimeException
(
\
sprintf
(
'Cache directory "%s" is not writable.'
,
$
directory
)
)
;
}
$
tmpFile
=
\
tempnam
(
$
directory
,
\
basename
(
$
filename
)
)
;
if
(
false
===
@
\
file_put_contents
(
$
tmpFile
,
$
content
)
)
{
throw
new
\
RuntimeException
(
\
sprintf
(
'Could not write file "%s".'
,
$
tmpFile
)
)
;
}
if
(
!
@
\
rename
(
$
tmpFile
,
$
filename
)
)
{
throw
new
\
RuntimeException
(
\
sprintf
(
'Could not write file "%s".'
,
$
filename
)
)
;
}
@
\
chmod
(
$
filename
,
0666
&
~
\
umask
(
)
)
;
}

Write PHP file

@param string $filename
@param string $content


public function getHydratorClass() : string
    {
        $originalClassName = $this->configuration->getHydratedClassName();
        $realClassName = $this->generateClassName($originalClassName);

        if (!class_exists($realClassName)) {

            $directory = $directory = $this->configuration->getGeneratedClassesTargetDir();
            $targetFile = $directory . '/' . \str_replace("\\", "_", $realClassName) . '.php';

            if (@include_once $targetFile) {
                return $realClassName;
            }

            $generator = $this->configuration->getHydratorGenerator();
            $phpClassCode = $generator->generate(new \ReflectionClass($originalClassName), $realClassName, $originalClassName);
            $this->writeFile($targetFile, $phpClassCode);

            require_once $targetFile;
        }

        return $realClassName;
    }

public function getHydratorClass ( ) : string { $ originalClassName = $ this -> configuration -> getHydratedClassName ( ) ; $ realClassName = $ this -> generateClassName ( $ originalClassName ) ; if ( ! class_exists ( $ realClassName ) ) { $ directory = $ directory = $ this -> configuration -> getGeneratedClassesTargetDir ( ) ; $ targetFile = $ directory . '/' . \ str_replace ( "\\" , "_" , $ realClassName ) . '.php' ; if ( @ include_once $ targetFile ) { return $ realClassName ; } $ generator = $ this -> configuration -> getHydratorGenerator ( ) ; $ phpClassCode = $ generator -> generate ( new \ ReflectionClass ( $ originalClassName ) , $ realClassName , $ originalClassName ) ; $ this -> writeFile ( $ targetFile , $ phpClassCode ) ; require_once $ targetFile ; } return $ realClassName ; }

Retrieves the generated hydrator FQCN

@return string


public function connect()
  {
    if($this->stream !== null) return;

    $host = strval($this->config["host"]);
    $port = strval($this->config["port"]);

    $address = "tcp://" . $host . ":" . $port;
    $timeout = intval($this->config["timeout"]);

    $this->stream = @stream_socket_client($address, $errno, $errstr, $timeout);

    if($this->stream === FALSE)
    {
      throw new Exception(utf8_encode($errstr), $errno);
    }

    @stream_set_timeout($this->stream, $timeout);
    @stream_set_blocking($this->stream, $this->config["blocking"] ? 1 : 0);
  }

public function connect ( ) { if ( $ this -> stream !== null ) return ; $ host = strval ( $ this -> config [ "host" ] ) ; $ port = strval ( $ this -> config [ "port" ] ) ; $ address = "tcp://" . $ host . ":" . $ port ; $ timeout = intval ( $ this -> config [ "timeout" ] ) ; $ this -> stream = @ stream_socket_client ( $ address , $ errno , $ errstr , $ timeout ) ; if ( $ this -> stream === FALSE ) { throw new Exception ( utf8_encode ( $ errstr ) , $ errno ) ; } @ stream_set_timeout ( $ this -> stream , $ timeout ) ; @ stream_set_blocking ( $ this -> stream , $ this -> config [ "blocking" ] ? 1 : 0 ) ; }

Connects to a remote server.

@throws Exception
@return void


public function disconnect()
  {
    if($this->stream === null) return;

	fclose($this->stream);
    $this->stream = null;

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "Disconnected");
  }

public function disconnect ( ) { if ( $ this -> stream === null ) return ; fclose ( $ this -> stream ) ; $ this -> stream = null ; \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Signal :: getInstance ( ) -> emit ( strtolower ( $ this -> getAdapterType ( ) ) . "Disconnected" ) ; }

Disconnects from a remote server.

@return void


public function readLine($token = "\n", $useCR = false)
  {
    $this->connect();

    $line = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String::factory("");

    while(!$line->endsWith($token) && !($useCR && $line->endsWith("\r"))) // FUUUUUUU carriage return
    {
      $this->waitForReadyRead();

      $data = @fgets($this->stream, 4096);

      \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);

      if($data === FALSE)
      {
        if($line->count())
        {
          $line->append($token);
        }
        else
        {
          throw new Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
        }
      }
      else
      {
        $line->append($data);
      }
    }

    return $line->trim();
  }

public
function
readLine
(
$
token
=
"\n"
,
$
useCR
=
false
)
{
$
this
->
connect
(
)
;
$
line
=
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
String
::
factory
(
""
)
;
while
(
!
$
line
->
endsWith
(
$
token
)
&&
!
(
$
useCR
&&
$
line
->
endsWith
(
"\r"
)
)
)
// FUUUUUUU carriage return
{
$
this
->
waitForReadyRead
(
)
;
$
data
=
@
fgets
(
$
this
->
stream
,
4096
)
;
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
Signal
::
getInstance
(
)
->
emit
(
strtolower
(
$
this
->
getAdapterType
(
)
)
.
"DataRead"
,
$
data
)
;
if
(
$
data
===
FALSE
)
{
if
(
$
line
->
count
(
)
)
{
$
line
->
append
(
$
token
)
;
}
else
{
throw
new
Exception
(
"connection to server '"
.
$
this
->
config
[
"host"
]
.
":"
.
$
this
->
config
[
"port"
]
.
"' lost"
)
;
}
}
else
{
$
line
->
append
(
$
data
)
;
}
}
return
$
line
->
trim
(
)
;
}

Reads a single line of data from the stream.

@param  string $token
@throws Exception
@return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String

Reads a single line of data from the stream .


public function canCreate(ContainerInterface $container, $requestedName)
    {
        $fqcn = $this->getFQCN($requestedName);
        if ($fqcn === false) {
            return false;
        }

        return \class_exists($fqcn);
    }

public function canCreate ( ContainerInterface $ container , $ requestedName ) { $ fqcn = $ this -> getFQCN ( $ requestedName ) ; if ( $ fqcn === false ) { return false ; } return \ class_exists ( $ fqcn ) ; }

Can the factory create an instance for the service?

@param  ContainerInterface $container
@param  string $requestedName
@return bool


public function store(CreateRoleRequest $request)
    {
        $input = $request->all();

        $role = $this->roleRepository->create([
            'name' => $input['name'],
        ]);

        foreach ($input['permissions'] as $permission) {
            $role->permissions()->attach($permission);
        }

        \Flash::success(trans('l5starter::messages.create.success'));

        return redirect(route('admin.roles.index'));
    }

public function store ( CreateRoleRequest $ request ) { $ input = $ request -> all ( ) ; $ role = $ this -> roleRepository -> create ( [ 'name' => $ input [ 'name' ] , ] ) ; foreach ( $ input [ 'permissions' ] as $ permission ) { $ role -> permissions ( ) -> attach ( $ permission ) ; } \ Flash :: success ( trans ( 'l5starter::messages.create.success' ) ) ; return redirect ( route ( 'admin.roles.index' ) ) ; }

Store a newly created Role in storage.

@param CreateRoleRequest $request

@return Response


public function update($id, UpdateRoleRequest $request)
    {
        $role = $this->roleRepository->findWithoutFail($id);

        if (empty($role)) {
            \Flash::error(trans('l5starter::messages.404_not_found'));

            return redirect(route('admin.roles.index'));
        }

        $input = $request->all();

        $role = $this->roleRepository->update([
            'name' => $input['name'],
        ], $id);

        $permissions = [];

        if (!empty($input['permissions'])) {
            foreach ($input['permissions'] as $permission) {
                $permissions[$permission] = $permission;
            }
        }

        $role->permissions()->sync($permissions);

        \Flash::success(trans('l5starter::messages.update.success'));

        return redirect(route('admin.roles.index'));
    }

public function update ( $ id , UpdateRoleRequest $ request ) { $ role = $ this -> roleRepository -> findWithoutFail ( $ id ) ; if ( empty ( $ role ) ) { \ Flash :: error ( trans ( 'l5starter::messages.404_not_found' ) ) ; return redirect ( route ( 'admin.roles.index' ) ) ; } $ input = $ request -> all ( ) ; $ role = $ this -> roleRepository -> update ( [ 'name' => $ input [ 'name' ] , ] , $ id ) ; $ permissions = [ ] ; if ( ! empty ( $ input [ 'permissions' ] ) ) { foreach ( $ input [ 'permissions' ] as $ permission ) { $ permissions [ $ permission ] = $ permission ; } } $ role -> permissions ( ) -> sync ( $ permissions ) ; \ Flash :: success ( trans ( 'l5starter::messages.update.success' ) ) ; return redirect ( route ( 'admin.roles.index' ) ) ; }

Update the specified Role in storage.

@param  int $id
@param UpdateRoleRequest $request

@return Response


public function destroy($id)
    {
        $role = $this->roleRepository->findWithoutFail($id);

        if (empty($role)) {
            \Flash::error(trans('l5starter::messages.404_not_found'));

            return redirect(route('admin.roles.index'));
        }

        $this->roleRepository->delete($id);

        \Flash::success(trans('l5starter::messages.delete.success'));

        return redirect(route('admin.roles.index'));
    }

public function destroy ( $ id ) { $ role = $ this -> roleRepository -> findWithoutFail ( $ id ) ; if ( empty ( $ role ) ) { \ Flash :: error ( trans ( 'l5starter::messages.404_not_found' ) ) ; return redirect ( route ( 'admin.roles.index' ) ) ; } $ this -> roleRepository -> delete ( $ id ) ; \ Flash :: success ( trans ( 'l5starter::messages.delete.success' ) ) ; return redirect ( route ( 'admin.roles.index' ) ) ; }

Remove the specified Role from storage.

@param  int $id

@return Response

Remove the specified Role from storage .


public function get($resource, $headers = array())
    {
        return $this->getGuzzle()->request(
          'GET',
          $this->getUrl().$resource,
          ['headers' => array_merge($this->getHeaders(), $headers)]
        );
    }

public function get ( $ resource , $ headers = array ( ) ) { return $ this -> getGuzzle ( ) -> request ( 'GET' , $ this -> getUrl ( ) . $ resource , [ 'headers' => array_merge ( $ this -> getHeaders ( ) , $ headers ) ] ) ; }

Get resource.

@param string $resource
@param array  $headers

@return \Guzzle\Http\Message\Response


protected function getCorpusClass()
  {
    $extras = "";

    if($this->currObj instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Node\Channel && $this->currObj->isSpacer())
    {
      switch($this->currObj->spacerGetType())
      {
        case (string) \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_SOLIDLINE:
          $extras .= " solidline";
          break;

        case (string) \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DASHLINE:
          $extras .= " dashline";
          break;

        case (string) \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DASHDOTLINE:
          $extras .= " dashdotline";
          break;

        case (string) \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DASHDOTDOTLINE:
          $extras .= " dashdotdotline";
          break;

        case (string) \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DOTLINE:
          $extras .= " dotline";
          break;
      }

      switch($this->currObj->spacerGetAlign())
      {
        case \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_CENTER:
          $extras .= " center";
          break;

        case \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_RIGHT:
          $extras .= " right";
          break;

        case \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_LEFT:
          $extras .= " left";
          break;
      }
    }

    return "corpus " . $this->currObj->getClass(null) . $extras;
  }

protected
function
getCorpusClass
(
)
{
$
extras
=
""
;
if
(
$
this
->
currObj
instanceof
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Node
\
Channel
&&
$
this
->
currObj
->
isSpacer
(
)
)
{
switch
(
$
this
->
currObj
->
spacerGetType
(
)
)
{
case
(
string
)
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_SOLIDLINE
:
$
extras
.=
" solidline"
;
break
;
case
(
string
)
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_DASHLINE
:
$
extras
.=
" dashline"
;
break
;
case
(
string
)
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_DASHDOTLINE
:
$
extras
.=
" dashdotline"
;
break
;
case
(
string
)
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_DASHDOTDOTLINE
:
$
extras
.=
" dashdotdotline"
;
break
;
case
(
string
)
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_DOTLINE
:
$
extras
.=
" dotline"
;
break
;
}
switch
(
$
this
->
currObj
->
spacerGetAlign
(
)
)
{
case
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_ALIGN_CENTER
:
$
extras
.=
" center"
;
break
;
case
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_ALIGN_RIGHT
:
$
extras
.=
" right"
;
break
;
case
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_ALIGN_LEFT
:
$
extras
.=
" left"
;
break
;
}
}
return
"corpus "
.
$
this
->
currObj
->
getClass
(
)
.
$
extras
;
}

Returns a string for the current corpus element which can be used as a HTML class
property. If the current node is a channel spacer the class string will contain
additional class names to allow further customization of the content via CSS.

@return string

Returns a string for the current corpus element which can be used as a HTML class property . If the current node is a channel spacer the class string will contain additional class names to allow further customization of the content via CSS .


protected function getCorpusIcon()
  {
    if($this->currObj instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Node\Channel && $this->currObj->isSpacer()) return;

    return $this->getImage($this->currObj->getIcon() . ".png");
  }

protected function getCorpusIcon ( ) { if ( $ this -> currObj instanceof \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Node \ Channel && $ this -> currObj -> isSpacer ( ) ) return ; return $ this -> getImage ( $ this -> currObj -> getIcon ( ) . ".png" ) ; }

Returns a HTML img tag which can be used to display the status icon for a
TeamSpeak_Node_Abstract object.

@return string

Returns a HTML img tag which can be used to display the status icon for a TeamSpeak_Node_Abstract object .


protected function getCorpusName()
  {
    if($this->currObj instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Node\Channel && $this->currObj->isSpacer())
    {
      if($this->currObj->spacerGetType() != \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_CUSTOM) return;

      $string = $this->currObj["channel_name"]->section("]", 1);

      if($this->currObj->spacerGetAlign() == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_REPEAT)
      {
        $string->resize(30, $string);
      }

      return htmlspecialchars($string);
    }

    if($this->currObj instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Node\Client)
    {
      $before = array();
      $behind = array();

      foreach($this->currObj->memberOf() as $group)
      {
        if($group->getProperty("namemode") == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_NAMEMODE_BEFORE)
        {
          $before[] = "[" . htmlspecialchars($group["name"]) . "]";
        }
        elseif($group->getProperty("namemode") == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_NAMEMODE_BEHIND)
        {
          $behind[] = "[" . htmlspecialchars($group["name"]) . "]";
        }
      }

      return implode("", $before) . " " . htmlspecialchars($this->currObj) . " " . implode("", $behind);
    }

    return htmlspecialchars($this->currObj);
  }

protected
function
getCorpusName
(
)
{
if
(
$
this
->
currObj
instanceof
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Node
\
Channel
&&
$
this
->
currObj
->
isSpacer
(
)
)
{
if
(
$
this
->
currObj
->
spacerGetType
(
)
!=
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_CUSTOM
)
return
;
$
string
=
$
this
->
currObj
[
"channel_name"
]
->
section
(
"]"
,
1
)
;
if
(
$
this
->
currObj
->
spacerGetAlign
(
)
==
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_ALIGN_REPEAT
)
{
$
string
->
resize
(
30
,
$
string
)
;
}
return
htmlspecialchars
(
$
string
)
;
}
if
(
$
this
->
currObj
instanceof
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Node
\
Client
)
{
$
before
=
array
(
)
;
$
behind
=
array
(
)
;
foreach
(
$
this
->
currObj
->
memberOf
(
)
as
$
group
)
{
if
(
$
group
->
getProperty
(
"namemode"
)
==
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
GROUP_NAMEMODE_BEFORE
)
{
$
before
[
]
=
"["
.
htmlspecialchars
(
$
group
[
"name"
]
)
.
"]"
;
}
elseif
(
$
group
->
getProperty
(
"namemode"
)
==
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
GROUP_NAMEMODE_BEHIND
)
{
$
behind
[
]
=
"["
.
htmlspecialchars
(
$
group
[
"name"
]
)
.
"]"
;
}
}
return
implode
(
""
,
$
before
)
.
" "
.
htmlspecialchars
(
$
this
->
currObj
)
.
" "
.
implode
(
""
,
$
behind
)
;
}
return
htmlspecialchars
(
$
this
->
currObj
)
;
}

Returns a string for the current corpus element which contains the display name
for the current TeamSpeak_Node_Abstract object.

@return string

Returns a string for the current corpus element which contains the display name for the current TeamSpeak_Node_Abstract object .


protected function getSuffixFlag()
  {
    if(!$this->currObj instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Node\Client) return;

    if($this->flagpath && $this->currObj["client_country"])
    {
      return $this->getImage($this->currObj["client_country"]->toLower() . ".png", $this->currObj["client_country"], null, FALSE, TRUE);
    }
  }

protected function getSuffixFlag ( ) { if ( ! $ this -> currObj instanceof \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Node \ Client ) return ; if ( $ this -> flagpath && $ this -> currObj [ "client_country" ] ) { return $ this -> getImage ( $ this -> currObj [ "client_country" ] -> toLower ( ) . ".png" , $ this -> currObj [ "client_country" ] , null , FALSE , TRUE ) ; } }

Returns a HTML img tag which can be used to display the country flag for a
TeamSpeak_Node_Client object.

@return string

Returns a HTML img tag which can be used to display the country flag for a TeamSpeak_Node_Client object .


protected function init($ftkey)
  {
    if(strlen($ftkey) != 32)
    {
      throw new FileTransfer\Exception("invalid file transfer key format");
    }

    $this->getProfiler()->start();
    $this->getTransport()->send($ftkey);

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferHandshake", $this);
  }

protected
function
init
(
$
ftkey
)
{
if
(
strlen
(
$
ftkey
)
!=
32
)
{
throw
new
FileTransfer
\
Exception
(
"invalid file transfer key format"
)
;
}
$
this
->
getProfiler
(
)
->
start
(
)
;
$
this
->
getTransport
(
)
->
send
(
$
ftkey
)
;
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
Signal
::
getInstance
(
)
->
emit
(
"filetransferHandshake"
,
$
this
)
;
}

Sends a valid file transfer key to the server to initialize the file transfer.

@param  string $ftkey
@throws FileTransfer\Exception
@return void

Sends a valid file transfer key to the server to initialize the file transfer .


public function upload($ftkey, $seek, $data)
  {
    $this->init($ftkey);

    $size = strlen($data);
    $seek = intval($seek);
    $pack = 4096;

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferUploadStarted", $ftkey, $seek, $size);

    for(;$seek < $size;)
    {
      $rest = $size-$seek;
      $pack = $rest < $pack ? $rest : $pack;
      $buff = substr($data, $seek, $pack);
      $seek = $seek+$pack;

      $this->getTransport()->send($buff);

      \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferUploadProgress", $ftkey, $seek, $size);
    }

    $this->getProfiler()->stop();

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferUploadFinished", $ftkey, $seek, $size);

    if($seek < $size)
    {
      throw new FileTransfer\Exception("incomplete file upload (" . $seek . " of " . $size . " bytes)");
    }
  }

public
function
upload
(
$
ftkey
,
$
seek
,
$
data
)
{
$
this
->
init
(
$
ftkey
)
;
$
size
=
strlen
(
$
data
)
;
$
seek
=
intval
(
$
seek
)
;
$
pack
=
4096
;
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
Signal
::
getInstance
(
)
->
emit
(
"filetransferUploadStarted"
,
$
ftkey
,
$
seek
,
$
size
)
;
for
(
;
$
seek
<
$
size
;
)
{
$
rest
=
$
size
$
seek
;
$
pack
=
$
rest
<
$
pack
$
rest
:
$
pack
;
$
buff
=
substr
(
$
data
,
$
seek
,
$
pack
)
;
$
seek
=
$
seek
+
$
pack
;
$
this
->
getTransport
(
)
->
send
(
$
buff
)
;
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
Signal
::
getInstance
(
)
->
emit
(
"filetransferUploadProgress"
,
$
ftkey
,
$
seek
,
$
size
)
;
}
$
this
->
getProfiler
(
)
->
stop
(
)
;
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
Signal
::
getInstance
(
)
->
emit
(
"filetransferUploadFinished"
,
$
ftkey
,
$
seek
,
$
size
)
;
if
(
$
seek
<
$
size
)
{
throw
new
FileTransfer
\
Exception
(
"incomplete file upload ("
.
$
seek
.
" of "
.
$
size
.
" bytes)"
)
;
}
}

Sends the content of a file to the server.

@param  string  $ftkey
@param  integer $seek
@param  string  $data
@throws FileTransfer\Exception
@return void

Sends the content of a file to the server .


public function download($ftkey, $size, $passthru = FALSE)
  {
    $this->init($ftkey);

    if($passthru)
    {
      return $this->passthru($size);
    }

    $buff = new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String("");
    $size = intval($size);
    $pack = 4096;

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size);

    for($seek = 0;$seek < $size;)
    {
      $rest = $size-$seek;
      $pack = $rest < $pack ? $rest : $pack;
      $data = $this->getTransport()->read($rest < $pack ? $rest : $pack);
      $seek = $seek+$pack;

      $buff->append($data);

      \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size);
    }

    $this->getProfiler()->stop();

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size);

    if(strlen($buff) != $size)
    {
      throw new FileTransfer\Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)");
    }

    return $buff;
  }

public
function
download
(
$
ftkey
,
$
size
,
$
passthru
=
FALSE
)
{
$
this
->
init
(
$
ftkey
)
;
if
(
$
passthru
)
{
return
$
this
->
passthru
(
$
size
)
;
}
$
buff
=
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
String
(
""
)
;
$
size
=
intval
(
$
size
)
;
$
pack
=
4096
;
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
Signal
::
getInstance
(
)
->
emit
(
"filetransferDownloadStarted"
,
$
ftkey
,
count
(
$
buff
)
,
$
size
)
;
for
(
$
seek
=
0
;
$
seek
<
$
size
;
)
{
$
rest
=
$
size
$
seek
;
$
pack
=
$
rest
<
$
pack
$
rest
:
$
pack
;
$
data
=
$
this
->
getTransport
(
)
->
read
(
$
rest
<
$
pack
$
rest
:
$
pack
)
;
$
seek
=
$
seek
+
$
pack
;
$
buff
->
append
(
$
data
)
;
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
Signal
::
getInstance
(
)
->
emit
(
"filetransferDownloadProgress"
,
$
ftkey
,
count
(
$
buff
)
,
$
size
)
;
}
$
this
->
getProfiler
(
)
->
stop
(
)
;
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
Signal
::
getInstance
(
)
->
emit
(
"filetransferDownloadFinished"
,
$
ftkey
,
count
(
$
buff
)
,
$
size
)
;
if
(
strlen
(
$
buff
)
!=
$
size
)
{
throw
new
FileTransfer
\
Exception
(
"incomplete file download ("
.
count
(
$
buff
)
.
" of "
.
$
size
.
" bytes)"
)
;
}
return
$
buff
;
}

Returns the content of a downloaded file as a \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String object.

@param  string  $ftkey
@param  integer $size
@param  boolean $passthru
@throws FileTransfer\Exception
@return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String

Returns the content of a downloaded file as a \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ String object .


public function getSessionContext()
    {
        if (!$this->_sessionContext) {
            $this->_sessionContext = new SessionContext();
            $this->_sessionContext->retrieveSessionObjects();
        }
        return $this->_sessionContext;
    }

public function getSessionContext ( ) { if ( ! $ this -> _sessionContext ) { $ this -> _sessionContext = new SessionContext ( ) ; $ this -> _sessionContext -> retrieveSessionObjects ( ) ; } return $ this -> _sessionContext ; }

Get the SessionContext object

@return \Openbizx\Web\SessionContext the SessionContext object


public function getTypeManager()
    {
        if (!$this->_typeManager) {
            $this->_typeManager = new TypeManager();

            /* @var $localeInfoService localeInfoService */
            $localeInfoService = Openbizx::getService(LOCALEINFO_SERVICE);
            $localeInfo = $localeInfoService->getLocaleInfo();

            if ($localeInfo) {
                $this->_typeManager->setLocaleInfo($localeInfo);
            }
        }
        return $this->_typeManager;
    }

Get the TypeManager object

@return TypeManager the TypeManager object


public function getDBConnection($dbName = null)
    {
        $rDBName = (!$dbName) ? "Default" : $dbName;
        if (isset($this->_dbConnection[$rDBName])) {
            $db = $this->_dbConnection[$rDBName];
            if (!CLI) {
                return $db;
            }
        }

        $dbInfo = $this->getConfiguration()->getDatabaseInfo($rDBName);

        //require_once 'Zend/Db.php';

        $params = array(
            'host' => $dbInfo["Server"],
            'username' => $dbInfo["User"],
            'password' => $dbInfo["Password"],
            'dbname' => $dbInfo["DBName"],
            'port' => $dbInfo["Port"],
            'charset' => $dbInfo["Charset"]
        );
        if ($dbInfo["Options"]) {
            $options = explode(";", $dbInfo["Options"]);
            foreach ($options as $opt) {
                list($k, $v) = explode("=", $opt);
                $params[$k] = $v;
            }
        }
        foreach ($params as $name => $val) {
            if (empty($val)) {
                unset($params[$name]);
            }
        }
        if (strtoupper($dbInfo["Driver"]) == "PDO_MYSQL") {
            $pdoParams = array(
                \PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true
            );
            $params["driver_options"] = $pdoParams;
        }

        $db = \Zend_Db::factory($dbInfo["Driver"], $params);
        $db->setFetchMode(\PDO::FETCH_NUM);

        if (strtoupper($dbInfo["Driver"]) == "PDO_MYSQL" &&
                $dbInfo["Charset"] != "") {
            $db->query("SET NAMES '" . $params['charset'] . "'");
        }
        $this->_dbConnection[$rDBName] = $db;
        return $db;
    }

public
function
getDBConnection
(
$
dbName
=
)
{
$
rDBName
=
(
!
$
dbName
)
"Default"
:
$
dbName
;
if
(
isset
(
$
this
->
_dbConnection
[
$
rDBName
]
)
)
{
$
db
=
$
this
->
_dbConnection
[
$
rDBName
]
;
if
(
!
CLI
)
{
return
$
db
;
}
}
$
dbInfo
=
$
this
->
getConfiguration
(
)
->
getDatabaseInfo
(
$
rDBName
)
;
//require_once 'Zend/Db.php';
$
params
=
array
(
'host'
=>
$
dbInfo
[
"Server"
]
,
'username'
=>
$
dbInfo
[
"User"
]
,
'password'
=>
$
dbInfo
[
"Password"
]
,
'dbname'
=>
$
dbInfo
[
"DBName"
]
,
'port'
=>
$
dbInfo
[
"Port"
]
,
'charset'
=>
$
dbInfo
[
"Charset"
]
)
;
if
(
$
dbInfo
[
"Options"
]
)
{
$
options
=
explode
(
";"
,
$
dbInfo
[
"Options"
]
)
;
foreach
(
$
options
as
$
opt
)
{
list
(
$
k
,
$
v
)
=
explode
(
"="
,
$
opt
)
;
$
params
[
$
k
]
=
$
v
;
}
}
foreach
(
$
params
as
$
name
=>
$
val
)
{
if
(
empty
(
$
val
)
)
{
unset
(
$
params
[
$
name
]
)
;
}
}
if
(
strtoupper
(
$
dbInfo
[
"Driver"
]
)
==
"PDO_MYSQL"
)
{
$
pdoParams
=
array
(
\
PDO
::
MYSQL_ATTR_USE_BUFFERED_QUERY
=>
true
)
;
$
params
[
"driver_options"
]
=
$
pdoParams
;
}
$
db
=
\
Zend_Db
::
factory
(
$
dbInfo
[
"Driver"
]
,
$
params
)
;
$
db
->
setFetchMode
(
\
PDO
::
FETCH_NUM
)
;
if
(
strtoupper
(
$
dbInfo
[
"Driver"
]
)
==
"PDO_MYSQL"
&&
$
dbInfo
[
"Charset"
]
!=
""
)
{
$
db
->
query
(
"SET NAMES '"
.
$
params
[
'charset'
]
.
"'"
)
;
}
$
this
->
_dbConnection
[
$
rDBName
]
=
$
db
;
return
$
db
;
}

Get the database connection object

@param string $dbName    database name declared in config.xml
@return \Zend_Db_Adapter_Abstract


public function removeDBConnection($dbName = "Default")
    {
        if (isset($this->_dbConnection[$dbName])) {
            $this->_dbConnection[$dbName]->closeConnection();
            unset($this->_dbConnection[$dbName]);
        }
        return $this->getDBConnection($dbName);
    }

public function removeDBConnection ( $ dbName = "Default" ) { if ( isset ( $ this -> _dbConnection [ $ dbName ] ) ) { $ this -> _dbConnection [ $ dbName ] -> closeConnection ( ) ; unset ( $ this -> _dbConnection [ $ dbName ] ) ; } return $ this -> getDBConnection ( $ dbName ) ; }

Remove database connection by name
@param string $dbName
@return \Zend_Db_Adapter_Abstract


public function processSecurityFilters()
    {
        $securityService = Openbizx::getService(SECURITY_SERVICE);
        $securityService->processFilters();
        $err_msg = $securityService->getErrorMessage();
        if ($err_msg) {
            if ($this->_securityDeniedView) {
                $webpage = $this->_securityDeniedView;
            } else {
                $webpage = $this->_accessDeniedView;
            }
            $this->renderView($webpage);
            return false;
        }
        return true;
    }

public function processSecurityFilters ( ) { $ securityService = Openbizx :: getService ( SECURITY_SERVICE ) ; $ securityService -> processFilters ( ) ; $ err_msg = $ securityService -> getErrorMessage ( ) ; if ( $ err_msg ) { if ( $ this -> _securityDeniedView ) { $ webpage = $ this -> _securityDeniedView ; } else { $ webpage = $ this -> _accessDeniedView ; } $ this -> renderView ( $ webpage ) ; return false ; } return true ; }

Process Security Filters

@return boolean true if success, and false if have error


public function dispatchRequest()
    {
        if ($this->request->hasInvocation()) {
            if ($this->isSessionTimeout()) {
                $this->getSessionContext()->destroy();
                $this->getClientProxy()->redirectView($this->_userTimeoutView);
            }
            return $this->dispatchRPC();
        } else {
            return $this->dispatchView();
        }
    }

public function dispatchRequest ( ) { if ( $ this -> request -> hasInvocation ( ) ) { if ( $ this -> isSessionTimeout ( ) ) { $ this -> getSessionContext ( ) -> destroy ( ) ; $ this -> getClientProxy ( ) -> redirectView ( $ this -> _userTimeoutView ) ; } return $ this -> dispatchRPC ( ) ; } else { return $ this -> dispatchView ( ) ; } }

Dispatches client requests to proper objects, print the returned html text.

@return string

Dispatches client requests to proper objects print the returned html text .


private function getParameters()
    {
        $getKeys = array_keys($_GET);
        $params = null;
        // read parameters "param:name=value"
        foreach ($getKeys as $key) {
            if (substr($key, 0, 6) == "param:") {
                $paramName = substr($key, 6);
                $paramValue = $_GET[$key];
                $params[$paramName] = $paramValue;
            }
        }
        return $params;
    }

private
function
getParameters
(
)
{
$
getKeys
=
array_keys
(
$
_GET
)
;
$
params
=
;
// read parameters "param:name=value"
foreach
(
$
getKeys
as
$
key
)
{
if
(
substr
(
$
key
,
0
,
6
)
==
"param:"
)
{
$
paramName
=
substr
(
$
key
,
6
)
;
$
paramValue
=
$
_GET
[
$
key
]
;
$
params
[
$
paramName
]
=
$
paramValue
;
}
}
return
$
params
;
}

Get the parameter from the url

@return array parameter array


public function renderView($webpageName, $form = "", $rule = "", $params = null, $hist = "")
    {
        /* @var $webpage \Openbizx\Easy\WebPage */
        if ($webpageName == "__DynPopup") {
            $webpage = Openbizx::getWebpageObject($webpageName);
            return $webpage->render();
        }
        $this->setCurrentViewName($webpageName);
        $webpage = Openbizx::getWebpageObject($webpageName);
        if (!$webpage) {
            return '';
        }

        $viewSet = $webpage->getViewSet();
        $this->setCurrentViewSet($viewSet);
        $this->getSessionContext()->clearSessionObjects(true);

        if ($hist == "N") { // clean view history
            $webpage->cleanViewHistory();
        }
        if ($form != "" && $rule != "") {
            $webpage->processRule($form, $rule, TRUE);
        }
        if ($params) {
            $webpage->setParameters($params);
        }
        if (isset($_GET['mode'])) {   // can specify mode of form
            $webpage->setFormMode($form, $_GET['mode']);
        }
        return $webpage->render();
    }

Render a bizview

@param string $webpageName name of bizview
@param string $rule the search rule of a bizform who is not depent on (a subctrl of) another bizform
@return void


protected function validateRequest($obj, $methodName)
    {
        if (is_a($obj, "Openbizx\Easy\EasyForm") || is_a($obj, "BaseForm")) {
            if ($obj->validateRequest($methodName)) {
                return true;
            }
        }
        return false;
    }

protected function validateRequest ( $ obj , $ methodName ) { if ( is_a ( $ obj , "Openbizx\Easy\EasyForm" ) || is_a ( $ obj , "BaseForm" ) ) { if ( $ obj -> validateRequest ( $ methodName ) ) { return true ; } } return false ; }

Validate the request from client.

@param object $obj the to be called object
@param string $methodName the to be called method name
@return boolean


private function dispatchView()
    {
        $request = $this->request;

        if (!ObjectFactoryHelper::getXmlFileWithPath($request->view)) {
            return $this->renderNotFoundView();
        }
        if (!$this->canUserAccessView($request->view)) {  //access denied error
            return $this->renderView($this->_accessDeniedView);
        }
        return $this->renderView($request->view, $request->form, $request->rule, $request->params, $request->hist);
    }

private
function
dispatchView
(
)
{
$
request
=
$
this
->
request
;
if
(
!
ObjectFactoryHelper
::
getXmlFileWithPath
(
$
request
->
view
)
)
{
return
$
this
->
renderNotFoundView
(
)
;
}
if
(
!
$
this
->
canUserAccessView
(
$
request
->
view
)
)
{
//access denied error
return
$
this
->
renderView
(
$
this
->
_accessDeniedView
)
;
}
return
$
this
->
renderView
(
$
request
->
view
,
$
request
->
form
,
$
request
->
rule
,
$
request
->
params
,
$
request
->
hist
)
;
}


public function redirectToDefaultModuleView($pmodule)
    {
        $module = strtolower($pmodule);
        $modfile = $this->getModulePath() . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'mod.xml';
        $xml = simplexml_load_file($modfile);
        $defaultURL = OPENBIZ_APP_INDEX_URL . $xml->Menu->MenuItem['URL'];
        header("Location: $defaultURL");
    }

public
function
redirectToDefaultModuleView
(
$
pmodule
)
{
$
module
=
strtolower
(
$
pmodule
)
;
$
modfile
=
$
this
->
getModulePath
(
)
.
DIRECTORY_SEPARATOR
.
$
module
.
DIRECTORY_SEPARATOR
.
'mod.xml'
;
$
xml
=
simplexml_load_file
(
$
modfile
)
;
$
defaultURL
=
OPENBIZ_APP_INDEX_URL
.
$
xml
->
Menu
->
MenuItem
[
'URL'
]
;
header
(
"Location: $defaultURL"
)
;
}

Goto default view of module

@param string $pmodule
@todo need to move to front controller


public function redirectToDefaultUserView()
    {
        $profile = $this->getUserProfile();
        if ($profile['roleStartpage'][0]) {
            $DEFAULT_URL = OPENBIZ_APP_INDEX_URL . $profile['roleStartpage'][0];
        }
        header("Location: $DEFAULT_URL");
        exit;
    }

public
function
redirectToDefaultUserView
(
)
{
$
profile
=
$
this
->
getUserProfile
(
)
;
if
(
$
profile
[
'roleStartpage'
]
[
0
]
)
{
$
DEFAULT_URL
=
OPENBIZ_APP_INDEX_URL
.
$
profile
[
'roleStartpage'
]
[
0
]
;
}
header
(
"Location: $DEFAULT_URL"
)
;
exit
;
}

Goto default view of user

@todo have options : redirect or renderDefaultView


public function initUserProfile($username)
    {
        /* @var $profileService profileService */
        $profileService = Openbizx::getService(PROFILE_SERVICE);
        if (method_exists($profileService, 'InitProfile')) {
            $profile = $profileService->initProfile($username);
        } else {
            $profile = $profileService->getProfile($username);
        }
        $this->getSessionContext()->setVar("_USER_PROFILE", $profile);
        return $profile;
    }

Initialize User Profile

@param string $username
@return array Profile array
@todo need to move, only used in profileService


public function getUserPreference($attribute = null)
    {
        if (!ObjectFactoryHelper::getXmlFileWithPath(OPENBIZ_PREFERENCE_SERVICE)) {
            return null;
        }
        $preferenceService = Openbizx::getService(OPENBIZ_PREFERENCE_SERVICE);
        if (method_exists($preferenceService, 'getPreference')) {
            return $preferenceService->getPreference($attribute);
        } else {
            $preference = $this->getSessionContext()->getVar("_USER_PREFERENCE");
            return isset($preference[$attribute]) ? $preference[$attribute] : "";
        }
    }

public function getUserPreference ( $ attribute = null ) { if ( ! ObjectFactoryHelper :: getXmlFileWithPath ( OPENBIZ_PREFERENCE_SERVICE ) ) { return null ; } $ preferenceService = Openbizx :: getService ( OPENBIZ_PREFERENCE_SERVICE ) ; if ( method_exists ( $ preferenceService , 'getPreference' ) ) { return $ preferenceService -> getPreference ( $ attribute ) ; } else { $ preference = $ this -> getSessionContext ( ) -> getVar ( "_USER_PREFERENCE" ) ; return isset ( $ preference [ $ attribute ] ) ? $ preference [ $ attribute ] : "" ; } }

Get user preference

@param string $attribute key that representing attribute
@return mixed


public function getDefaultPerm($pgroup)
    {
        $group = strtolower($pgroup);
        switch ($group) {
            default:
            case 'owner':
                $setting = $this->getUserPreference('owner_perm');
                if ($setting != '') {
                    $perm_code = $setting;
                } else {
                    $perm_code = OPENBIZ_DEFAULT_OWNER_PERM;
                }
                break;
            case 'group':
                $setting = $this->getUserPreference('owner_group');
                if ($setting != '') {
                    $perm_code = $setting;
                } else {
                    $perm_code = OPENBIZ_DEFAULT_GROUP_PERM;
                }
                break;
            case 'other':
                $setting = $this->getUserPreference('owner_other');
                if ($setting != '') {
                    $perm_code = $setting;
                } else {
                    $perm_code = OPENBIZ_DEFAULT_OTHER_PERM;
                }
                break;
        }
        return $perm_code;
    }

public function getDefaultPerm ( $ pgroup ) { $ group = strtolower ( $ pgroup ) ; switch ( $ group ) { default : case 'owner' : $ setting = $ this -> getUserPreference ( 'owner_perm' ) ; if ( $ setting != '' ) { $ perm_code = $ setting ; } else { $ perm_code = OPENBIZ_DEFAULT_OWNER_PERM ; } break ; case 'group' : $ setting = $ this -> getUserPreference ( 'owner_group' ) ; if ( $ setting != '' ) { $ perm_code = $ setting ; } else { $ perm_code = OPENBIZ_DEFAULT_GROUP_PERM ; } break ; case 'other' : $ setting = $ this -> getUserPreference ( 'owner_other' ) ; if ( $ setting != '' ) { $ perm_code = $ setting ; } else { $ perm_code = OPENBIZ_DEFAULT_OTHER_PERM ; } break ; } return $ perm_code ; }

Get default user perm
@param type $pgroup
@return string


public function getCurrentViewName()
    {
        if ($this->_currentViewName == "") {
            $this->_currentViewName = $this->getSessionContext()->getVar("CVN"); // CVN stands for CurrentViewName
        }
        return $this->_currentViewName;
    }

public
function
getCurrentViewName
(
)
{
if
(
$
this
->
_currentViewName
==
""
)
{
$
this
->
_currentViewName
=
$
this
->
getSessionContext
(
)
->
getVar
(
"CVN"
)
;
// CVN stands for CurrentViewName
}
return
$
this
->
_currentViewName
;
}

Get the current view name

@return string current view name


public function setCurrentViewName($viewname)
    {
        $this->_currentViewName = $viewname;
        $this->getSessionContext()->setVar("CVN", $this->_currentViewName);   // CVN stands for CurrentViewName
    }

public
function
setCurrentViewName
(
$
viewname
)
{
$
this
->
_currentViewName
=
$
viewname
;
$
this
->
getSessionContext
(
)
->
setVar
(
"CVN"
,
$
this
->
_currentViewName
)
;
// CVN stands for CurrentViewName
}

Set the current view name

@param string $viewname new current view name


public function getCurrentViewSet()
    {
        if ($this->_currentViewSet == "") {
            $this->_currentViewSet = $this->getSessionContext()->getVar("CVS");
        }   // CVS stands for CurrentViewSet
        return $this->_currentViewSet;
    }

public
function
getCurrentViewSet
(
)
{
if
(
$
this
->
_currentViewSet
==
""
)
{
$
this
->
_currentViewSet
=
$
this
->
getSessionContext
(
)
->
getVar
(
"CVS"
)
;
}
// CVS stands for CurrentViewSet
return
$
this
->
_currentViewSet
;
}

Get the current view set

@return string current view set


public function setCurrentViewSet($viewSet)
    {
        $this->_currentViewSet = $viewSet;
        $this->getSessionContext()->setVar("CVS", $this->_currentViewSet);   // CVS stands for CurrentViewSet
    }

public
function
setCurrentViewSet
(
$
viewSet
)
{
$
this
->
_currentViewSet
=
$
viewSet
;
$
this
->
getSessionContext
(
)
->
setVar
(
"CVS"
,
$
this
->
_currentViewSet
)
;
// CVS stands for CurrentViewSet
}

Set current view set

@param <type> $viewSet


public function setBasePath($path)
    {
        $p = realpath($path);
        if ($p !== false && is_dir($p)) {
            $this->_basePath = $p;
        } else {
            throw new Exception("The directory does not exist: $path");
        }
    }

public
function
setBasePath
(
$
path
)
{
$
p
=
realpath
(
$
path
)
;
if
(
$
p
!==
false
&&
is_dir
(
$
p
)
)
{
$
this
->
_basePath
=
$
p
;
}
else
{
throw
new
Exception
(
"The directory does not exist: $path"
)
;
}
}

Sets the root directory of the application.
This method can only be invoked at the beginning of the constructor.

@param string $path the root directory of the application.
@throws InvalidParamException if the directory does not exist.

Sets the root directory of the application . This method can only be invoked at the beginning of the constructor .


public function getModulePath()
    {
        if ($this->_modulePath === null) {
            $this->_modulePath = OPENBIZ_APP_PATH . DIRECTORY_SEPARATOR . "modules";
        }
        return $this->_modulePath;
    }

public function getModulePath ( ) { if ( $ this -> _modulePath === null ) { $ this -> _modulePath = OPENBIZ_APP_PATH . DIRECTORY_SEPARATOR . "modules" ; } return $ this -> _modulePath ; }

Get module path of application.
@return string


public function hashSQL($data, $columns, string $hash)
	{
		if (is_string($columns)) {
			$columns = [$columns];
		}

		if (is_array($columns)) {
			if ($data instanceof DbalCollection) {
				$data = $data->getQueryBuilder();
			}

			if ($data instanceof Selection) {
				$col = '';
				foreach ($columns as $column) {
					if ($col !== '') {
						$col += ',';
					}
					$col += '`$column`';
				}
				return $data->where("SHA2(CONCAT($columns,  '{$this->salt}'), 256)", $hash);
			} elseif ($data instanceof QueryBuilder) {
				return $data->andWhere('SHA2(CONCAT(%column[], %s), 256) = %s', $columns, $this->salt, $hash);
			}
		}
		throw new InvalidArgumentException;
	}

Vyhleda podle hashe
@param Selection|QueryBuilder|DbalCollection $data
@param string|array $columns
@param string $hash
@return Selection|QueryBuilder
@throws InvalidArgumentException


public function check($string, string $hash): bool
	{
		return hash_equals($this->hash($string), $hash);
	}

public function check ( $ string , string $ hash ) : bool { return hash_equals ( $ this -> hash ( $ string ) , $ hash ) ; }

Zkontroluje zda je hash vytvoren z daneho retezce
@param mixed $string
@param string $hash
@return bool


protected function readMetadata(&$xmlArr)
    {
        parent::readMetaData($xmlArr);
        $this->accounts = new MetaIterator($xmlArr["PLUGINSERVICE"]["ACCOUNTS"]["ACCOUNT"], "EmailAccount");
        $this->_logEnabled = $xmlArr["PLUGINSERVICE"]["LOGGING"]["ATTRIBUTES"]["ENABLED"];
        if ($this->_logEnabled) {
            $this->_logType = $xmlArr["PLUGINSERVICE"]["LOGGING"]["ATTRIBUTES"]["TYPE"];
            $this->_logObject = $xmlArr["PLUGINSERVICE"]["LOGGING"]["ATTRIBUTES"]["OBJECT"];
        }
    }

protected function readMetadata ( & $ xmlArr ) { parent :: readMetaData ( $ xmlArr ) ; $ this -> accounts = new MetaIterator ( $ xmlArr [ "PLUGINSERVICE" ] [ "ACCOUNTS" ] [ "ACCOUNT" ] , "EmailAccount" ) ; $ this -> _logEnabled = $ xmlArr [ "PLUGINSERVICE" ] [ "LOGGING" ] [ "ATTRIBUTES" ] [ "ENABLED" ] ; if ( $ this -> _logEnabled ) { $ this -> _logType = $ xmlArr [ "PLUGINSERVICE" ] [ "LOGGING" ] [ "ATTRIBUTES" ] [ "TYPE" ] ; $ this -> _logObject = $ xmlArr [ "PLUGINSERVICE" ] [ "LOGGING" ] [ "ATTRIBUTES" ] [ "OBJECT" ] ; } }

Read array meta-data, and store to meta-object

@param array $xmlArr
@return void

Read array meta - data and store to meta - object


public function useAccount($accountName)
    {
        //If a mail object exists, overwrite with new object
        if ($this->_mail)
            $this->_constructMail();

        $this->useAccount = $accountName;
        $account = $this->accounts->get($accountName);

        if ($account->isSMTP == "Y") {
            if ($account->sMTPAuth == "Y") {
                $config = array('auth' => 'login', 'username' => $account->username, 'password' => $account->password, "port" => $account->port, 'ssl' => $account->sSL);
            } else {
                $config = array();
            }
            $mailTransport = new \Zend_Mail_Transport_Smtp($account->host, $config);
            $this->_mail->setDefaultTransport($mailTransport);
        } else {
            require_once 'Zend/Mail/Transport/Sendmail.php';
            $mailTransport = new \Zend_Mail_Transport_Sendmail();
            $this->_mail->setDefaultTransport($mailTransport);
        }
        $this->_mail->setFrom($account->fromEmail, $account->fromName);
        return $this;
    }

Will set the Default Transport object for the mail object based on the supplied accountname

@param string $accountName
@return boolean TRUE/FALSE


public function sendEmail($TOs = null, $CCs = null, $BCCs = null, $subject, $body, $attachments = null, $isHTML = false)
    {
        $mail = $this->_mail;
        // add TO addresses
        if ($TOs) {
            foreach ($TOs as $to) {
                if (is_array($to)) {
                    $mail->addTo($to['email'], $to['name']);
                } else {
                    $mail->addTo($to);
                }
            }
        }
        // add CC addresses
        if ($CCs) {
            foreach ($CCs as $cc) {
                if (is_array($cc)) {
                    $mail->AddCC($cc['email'], $cc['name']);
                } else {
                    $mail->AddCC($cc);
                }
            }
        }
        // add BCC addresses
        if ($BCCs) {
            foreach ($BCCs as $bcc) {
                if (is_array($bcc)) {
                    $mail->AddBCC($bcc['email'], $bcc['name']);
                } else {
                    $mail->AddBCC($bcc);
                }
            }
        }
        // add attachments
        if ($attachments)
            foreach ($attachments as $att)
                $mail->CreateAttachment(file_get_contents($att));
        $mail->setSubject($subject);
        $body = str_replace("\\n", "\n", $body);
        if ($isHTML == TRUE) {
            $mail->setBodyHTML($body);
        } else {
            $mail->setBodyText($body);
        }

        try {
            $result = $mail->Send(); //Will throw an exception if sending fails
            $this->logEmail('Success', $subject, $body, $TOs, $CCs, $BCCs);
            return TRUE;
        } catch (Exception $e) {
            $result = "ERROR: " . $e->getMessage();
            $this->logEmail($result, $subject, $body, $TOs, $CCs, $BCCs);
            return FALSE;
        }
    }

A convenience function that will issue an email based on the parameter provided
Will log email attempts but will NOT run the body through a template

@param array $TOs
@param array $CCs
@param array $BCCs
@param array $subject
@param array $body
@param array $attachments
@param boolean $isHTML
@return boolean $result - TRUE on success, FALSE on failure


public function logEmail($result, $subject, $body = NULL, $TOs = NULL, $CCs = NULL, $BCCs = NULL)
    {
        //Log the email attempt
        $recipients = '';
        // add TO addresses
        if ($TOs) {
            foreach ($TOs as $to) {
                if (is_array($to)) {
                    $recipients .= $to['name'] . "<" . $to['email'] . ">;";
                } else {
                    $recipients .= $to . ";";
                }
            }
        }
        // add CC addresses
        if ($CCs) {
            foreach ($CCs as $cc) {
                if (is_array($cc)) {
                    $recipients .= $cc['name'] . "<" . $cc['email'] . ">;";
                } else {
                    $recipients .= $cc . ";";
                }
            }
        }
        // add BCC addresses
        if ($BCCs) {
            foreach ($BCCs as $bcc) {
                if (is_array($bcc)) {
                    $recipients .= $bcc['name'] . "<" . $bcc['email'] . ">;";
                } else {
                    $recipients .= $bcc . ";";
                }
            }
        }
        if ($this->_logType == 'DB') {
            $account = $this->accounts->get($this->useAccount);
            $sender_name = $account->fromName;
            $sender = $account->fromEmail;

            // Store the message log
            $boMessageLog = Openbizx::getObject($this->_logObject);
            $mlArr = $boMessageLog->newRecord();
            $mlArr["sender"] = $sender;
            $mlArr["sender_name"] = $sender_name;
            $mlArr["recipients"] = $recipients;
            $mlArr["subject"] = $subject;
            $mlArr["content"] = $body;
            $mlArr["result"] = $result;
            /*
             * as long as data could read from db, its no longer need to addslashes
              //Escape Data since this may contain quotes or other goodies
              foreach ($mlArr as $key => $value)
              {
              $mlArr[$key] = addslashes($value);
              }
             */
            $ok = $boMessageLog->insertRecord($mlArr);
            if (!$ok) {
                return $boMessageLog->getErrorMessage();
            } else {
                return TRUE;
            }
        } else {
            $back_trace = debug_backtrace();
            if ($result == 'Success') {
                $logNum = LOG_INFO;
            } else {
                $logNum = LOG_ERR;
            }
            Openbizx::$app->getLog()->log($logNum, "EmailService", "Sent email with subject - \"$subject\" and body - $body to - $recipients with result $result.", NULL, $back_trace);
        }
    }

Log that an email attemp was made.
We assume it was successfull, since \Zend_Mail throws an exception otherwise

@param string $subject
@param array $To
@param array $CCs
@param array $BCCs
@return mixed boolean|string|void

Log that an email attemp was made . We assume it was successfull since \ Zend_Mail throws an exception otherwise


public function Info($tag = mull)
    {
        if (empty($tag))
            trigger_error("You didn't supply a tag, not sure what whill happen here...", E_USER_WARNING);

        return $this->Get($this->buildUrl($tag));
    }

Gets infor about a particular tag
@access public
@param string $tag A tag name
@param string $token An access token
@return Response


public static function getAutoloadLibFileWithPath($className)
    {
        if (!$className) {
            return;
        }

        // use class map first
        if (isset(self::$classMap[$className])) {
            return self::$classMap[$className];
        }

        // search it in cache first
        $cacheKey = $className . "_path";
        if (extension_loaded('apc') && ($filePath = apc_fetch($cacheKey)) != null) {
            return $filePath;
        }

        $filePath = self::getCoreLibFilePath($className);

        // cache it to save file search
        if ($filePath && extension_loaded('apc')) {
            apc_store($cacheKey, $filePath);
        }
        return $filePath;
    }

public
static
function
getAutoloadLibFileWithPath
(
$
className
)
{
if
(
!
$
className
)
{
return
;
}
// use class map first
if
(
isset
(
self
::
$
classMap
[
$
className
]
)
)
{
return
self
::
$
classMap
[
$
className
]
;
}
// search it in cache first
$
cacheKey
=
$
className
.
"_path"
;
if
(
extension_loaded
(
'apc'
)
&&
(
$
filePath
=
apc_fetch
(
$
cacheKey
)
)
!=
)
{
return
$
filePath
;
}
$
filePath
=
self
::
getCoreLibFilePath
(
$
className
)
;
// cache it to save file search
if
(
$
filePath
&&
extension_loaded
(
'apc'
)
)
{
apc_store
(
$
cacheKey
,
$
filePath
)
;
}
return
$
filePath
;
}

Get openbiz library php file path for autoload, remove metadata package searching

@param string $className
@return string php library file path

Get openbiz library php file path for autoload remove metadata package searching


public static function loadMetadataClass($className, $packageName = '')
    {
        if (class_exists($className, false)) {
            return true;
        }
        if (isset(self::$_classNameCache[$packageName . $className])) {
            return true;
        }
        $filePath = self::getLibFileWithPath($className, $packageName);
        if ($filePath) {
            include_once($filePath);
            self::$_classNameCache[$packageName . $className] = 1;
            return true;
        }
        return false;
    }

public static function loadMetadataClass ( $ className , $ packageName = '' ) { if ( class_exists ( $ className , false ) ) { return true ; } if ( isset ( self :: $ _classNameCache [ $ packageName . $ className ] ) ) { return true ; } $ filePath = self :: getLibFileWithPath ( $ className , $ packageName ) ; if ( $ filePath ) { include_once ( $ filePath ) ; self :: $ _classNameCache [ $ packageName . $ className ] = 1 ; return true ; } return false ; }

Load class of MetaObject

@param type $className
@param type $packageName
@return boolean


public static function getCoreLibFilePath($className)
    {
        // if class not yet collect on class map, scan core path.
        $classFile = $className . '.php';
        // TODO: search the file under bin/, bin/data, bin/ui. bin/service, bin/easy, bin/Easy/element.
        // guess class type and folder
        $lowClassName = strtolower($className);
        if (strrpos($lowClassName, 'service') > 0) {
            $corePaths = array('service/');
        } else if (strrpos($lowClassName, 'form') > 0 || strrpos($lowClassName, 'form') === 0) {
            $corePaths = array('easy/');
        } else if (strrpos($lowClassName, 'view') > 0 || strrpos($lowClassName, 'view') === 0) {
            $corePaths = array('easy/');
        } else if (strrpos($lowClassName, 'dataobj') > 0) {
            $corePaths = array('data/');
        } else {
            $corePaths = array('easy/element/', '', 'data/', 'easy/', 'service/');
        }
        //$corePaths = array('', 'data/', 'easy/', 'easy/element/', 'ui/', 'service/');
        foreach ($corePaths as $path) {
            $_classFile = OPENBIZ_BIN . $path . $classFile;
            //echo "file_exists($_classFile)\n";
            if (file_exists($_classFile)) {
                return $_classFile;
            }
        }
        return null;
    }

Get core path of class

@param string $className class name
@return string full file name of class


private static function findClassFileOnCache($className) {
        // search it in cache first
        $cacheKey = $className . "_path";
        if (extension_loaded('apc') ) {
            $filePath = apc_fetch($cacheKey);
            return $filePath;
        }
        return null;
    }

private
static
function
findClassFileOnCache
(
$
className
)
{
// search it in cache first
$
cacheKey
=
$
className
.
"_path"
;
if
(
extension_loaded
(
'apc'
)
)
{
$
filePath
=
apc_fetch
(
$
cacheKey
)
;
return
$
filePath
;
}
return
;
}

Find class file location from cache dictionary.
@param type $className
@return string|null full path filename if found or null if not found

Find class file location from cache dictionary .


protected static function fill(Person $person, array $attrs)
    {
        $attrs = array_merge(
            $attrs,
            $attrs["PersonAffiliations"]["AlumPersonAffiliation"]
        );

        return parent::fill($person, $attrs);
    }

protected static function fill ( Person $ person , array $ attrs ) { $ attrs = array_merge ( $ attrs , $ attrs [ "PersonAffiliations" ] [ "AlumPersonAffiliation" ] ) ; return parent :: fill ( $ person , $ attrs ) ; }

Create an Alumni from a Person and a set of supplementary attributes.

@param Person $person
@param array  $attrs
@return Alumni

Create an Alumni from a Person and a set of supplementary attributes .


public function offsetSet($name, $job)
    {
        if (!is_callable($job)) {
            throw new InvalidArgumentException('Each job must be callable');
        }
        $this->jobs[$name] = $job;
    }

public
function
offsetSet
(
$
name
,
$
job
)
{
if
(
!
is_callable
(
$
job
)
)
{
throw
new
InvalidArgumentException
(
'Each job must be callable'
)
;
}
$
this
->
jobs
[
$
name
]
=
$
job
;
}

Add a job to the schedule.

@param string $name
@param callable $job The job.


public function process() : void
    {
        global $argv;
        $specific = null;
        foreach ($argv as $arg) {
            if (preg_match('@--job=(.*?)$@', $arg, $match)) {
                $specific = $match[1];
            }
        }
        $start = time();
        $tmp = sys_get_temp_dir();
        array_walk($this->jobs, function ($job, $idx) use ($tmp, $specific, $argv) {
            if (isset($specific) && $specific !== $idx) {
                return;
            }
            if (in_array('--verbose', $argv) || in_array('-v', $argv)) {
                echo "Starting $idx...";
            }
            $fp = fopen("$tmp/".md5($idx).'.lock', 'w+');
            flock($fp, LOCK_EX);
            try {
                $job->call($this);
            } catch (NotDueException $e) {
            } catch (Exception $e) {
                $this->logger->addCritial(sprintf(
                    "%s in file %s on line %d",
                    $e->getMessage(),
                    $e->getFile(),
                    $e->getLine()
                ));
            }
            flock($fp, LOCK_UN);
            fclose($fp);
            if (in_array('--verbose', $argv) || in_array('-v', $argv)) {
                echo " [done]\n";
            }
        });
        if (--$this->minutes > 0) {
            $wait = max(60 - (time() - $start), 0);
            if (!getenv('TOAST')) {
                sleep($wait);
            }
            $this->now += 60;
            $this->process();
        }
    }

public
function
process
(
)
:
void
{
global
$
argv
;
$
specific
=
;
foreach
(
$
argv
as
$
arg
)
{
if
(
preg_match
(
'@--job=(.*?)$@'
,
$
arg
,
$
match
)
)
{
$
specific
=
$
match
[
1
]
;
}
}
$
start
=
time
(
)
;
$
tmp
=
sys_get_temp_dir
(
)
;
array_walk
(
$
this
->
jobs
,
function
(
$
job
,
$
idx
)
use
(
$
tmp
,
$
specific
,
$
argv
)
{
if
(
isset
(
$
specific
)
&&
$
specific
!==
$
idx
)
{
return
;
}
if
(
in_array
(
'--verbose'
,
$
argv
)
||
in_array
(
'-v'
,
$
argv
)
)
{
echo
"Starting $idx..."
;
}
$
fp
=
fopen
(
"$tmp/"
.
md5
(
$
idx
)
.
'.lock'
,
'w+'
)
;
flock
(
$
fp
,
LOCK_EX
)
;
try
{
$
job
->
call
(
$
this
)
;
}
catch
(
NotDueException
$
e
)
{
}
catch
(
Exception
$
e
)
{
$
this
->
logger
->
addCritial
(
sprintf
(
"%s in file %s on line %d"
,
$
e
->
getMessage
(
)
,
$
e
->
getFile
(
)
,
$
e
->
getLine
(
)
)
)
;
}
flock
(
$
fp
,
LOCK_UN
)
;
fclose
(
$
fp
)
;
if
(
in_array
(
'--verbose'
,
$
argv
)
||
in_array
(
'-v'
,
$
argv
)
)
{
echo
" [done]\n"
;
}
}
)
;
if
(
$
this
->
minutes
>
0
)
{
$
wait
=
max
(
60
(
time
(
)
$
start
)
,
0
)
;
if
(
!
getenv
(
'TOAST'
)
)
{
sleep
(
$
wait
)
;
}
$
this
->
now
+=
60
;
$
this
->
process
(
)
;
}
}

Process the schedule and run all jobs which are due.

@return void

Process the schedule and run all jobs which are due .


public function at(string $datestring) : void
    {
        global $argv;
        if (in_array('--all', $argv) || in_array('-a', $argv)) {
            return;
        }
        $date = date($datestring, $this->now);
        if (!preg_match("@$date$@", date('Y-m-d H:i', $this->now))) {
            throw new NotDueException;
        }
    }

public
function
at
(
string
$
datestring
)
:
void
{
global
$
argv
;
if
(
in_array
(
'--all'
,
$
argv
)
||
in_array
(
'-a'
,
$
argv
)
)
{
return
;
}
$
date
=
date
(
$
datestring
,
$
this
->
now
)
;
if
(
!
preg_match
(
"@$date$@"
,
date
(
'Y-m-d H:i'
,
$
this
->
now
)
)
)
{
throw
new
NotDueException
;
}
}

The job should run "at" the specified time.

@param string $datestring A string parsable by `date` that should match
the current script runtime for the job to execute.
@return void
@throws Monolyth\Croney\NotDueException if the task isn't due yet.

The job should run at the specified time .


public function renderLabel()
    {
        if ($this->sortable == "Y")
        {
            $rule = $this->objectName;

            $function = $this->formName . ".SortRecord($rule,$this->sortFlag)";
            if($this->sortFlag == "ASC" || $this->sortFlag == "DESC"){
            	$class=" class=\"current\" ";
            }else{
            	$class=" class=\"normal\" ";
            }
            if ($this->sortFlag == "ASC")
            	$span_class = " class=\"sort_up\" ";
            else if ($this->sortFlag == "DESC")
                $span_class = " class=\"sort_down\" ";
            $sHTML = "" . $this->label ."";
            $sHTML .= "";
        }
        else
        {
            $sHTML = $this->label;
        }
        return $sHTML;
    }

When render table, it return the table header; when render array, it return the display name

@return string HTML text

When render table it return the table header ; when render array it return the display name


protected static function flattenPath(array $path)
    {
        $string = '';

        foreach ($path as $i => $segment) {
            if (\is_numeric($segment)) {
                $string .= '[' . $segment . ']';

                continue;
            }

            if ($i != 0) {
                $string .= '.';
            }

            if (\is_array($segment)) {
                $string .= $segment[0] . '(';

                foreach ($segment[1] as $j => $arg) {
                    if ($j != 0) {
                        $string .= ', ';
                    }

                    $string .= $arg;
                }

                $string .= ')';
            } else {
                $string .= $segment;
            }
        }

        return $string;
    }

protected
static
function
flattenPath
(
array
$
path
)
{
$
string
=
''
;
foreach
(
$
path
as
$
i
=>
$
segment
)
{
if
(
\
is_numeric
(
$
segment
)
)
{
$
string
.=
'['
.
$
segment
.
']'
;
continue
;
}
if
(
$
i
!=
0
)
{
$
string
.=
'.'
;
}
if
(
\
is_array
(
$
segment
)
)
{
$
string
.=
$
segment
[
0
]
.
'('
;
foreach
(
$
segment
[
1
]
as
$
j
=>
$
arg
)
{
if
(
$
j
!=
0
)
{
$
string
.=
', '
;
}
$
string
.=
$
arg
;
}
$
string
.=
')'
;
}
else
{
$
string
.=
$
segment
;
}
}
return
$
string
;
}

Flatten the given exploded path into a string representation.

@param array $path
@return string

Flatten the given exploded path into a string representation .


public function getConfig()
    {
        $provider = new ConfigProvider();

        $this->config = $provider->getTemplateConfig();
        $this->config['middleware_pipeline']    = $provider->getMiddlewareConfig();
        $this->config['service_manager']        = $provider->getDependencyConfig();
        $this->config['router']['routes']       = $provider->getRouteConfig();
        $this->config['navigation']             = $provider->getNavigationConfig();
        $this->config['controllers']            = $provider->getControllerConfig();
        $this->config['controller_plugins']     = $provider->getControllerPluginConfig();

        // Overrides the default config to use Glob module config
        return array_merge_recursive($this->config, $provider->getGlobConfig());
    }

Return default configuration for zend-mvc applications.

Return default configuration for zend - mvc applications .


public function Create($url, $method = 'GET', $parameters = array())
	{
		$ch = curl_init();
		$key= (string)$ch;
		$query = '';
		$res = null;

		$options = $this->_options;

		foreach ($parameters as $k => $v)
			$query .= ((strlen ($query) == 0) ? "":"&") . sprintf('%s=%s', $k, urlencode($v));

		switch (strtolower($method))
		{
			case 'post':
				$options[CURLOPT_POST] = true;
				$options[CURLOPT_POSTFIELDS] = $query;
				break;
			case 'delete':
				$options[CURLOPT_CUSTOMREQUEST] = 'DELETE';
				$url .= '?' . $query;
				break;
			default:
				$url .= '?' . $query;
				break;
		}

		$options[CURLOPT_URL] = $url;
		curl_setopt_array($ch, $options);

		$this->_requests[$key] = $ch;

		$res = curl_multi_add_handle($this->mh, $this->_requests[$key]);
		if ($res == CURLM_OK) {
			curl_multi_exec($this->mh, $active);
			return new WebRequestManager($key, $this->config);
		}
		return new Error('cURLError', curl_error($ch), curl_errno($ch), $options[CURLOPT_URL]);
	}

public function Create ( $ url , $ method = 'GET' , $ parameters = array ( ) ) { $ ch = curl_init ( ) ; $ key = ( string ) $ ch ; $ query = '' ; $ res = null ; $ options = $ this -> _options ; foreach ( $ parameters as $ k => $ v ) $ query .= ( ( strlen ( $ query ) == 0 ) ? "" : "&" ) . sprintf ( '%s=%s' , $ k , urlencode ( $ v ) ) ; switch ( strtolower ( $ method ) ) { case 'post' : $ options [ CURLOPT_POST ] = true ; $ options [ CURLOPT_POSTFIELDS ] = $ query ; break ; case 'delete' : $ options [ CURLOPT_CUSTOMREQUEST ] = 'DELETE' ; $ url .= '?' . $ query ; break ; default : $ url .= '?' . $ query ; break ; } $ options [ CURLOPT_URL ] = $ url ; curl_setopt_array ( $ ch , $ options ) ; $ this -> _requests [ $ key ] = $ ch ; $ res = curl_multi_add_handle ( $ this -> mh , $ this -> _requests [ $ key ] ) ; if ( $ res == CURLM_OK ) { curl_multi_exec ( $ this -> mh , $ active ) ; return new WebRequestManager ( $ key , $ this -> config ) ; } return new Error ( 'cURLError' , curl_error ( $ ch ) , curl_errno ( $ ch ) , $ options [ CURLOPT_URL ] ) ; }

Creates a new cURL reuest and adds to the request queue for processing
@param string $url The url in which to make the request
@param string $method The method used to make the request [GET|POST|DELETE]
@param array $parameters Array of key/value pairs to pass to the request
@return mixed A WebRequestManager to manage the current request on success, Error on failure
@access public


private function store()
	{
		while ($finished = curl_multi_info_read($this->mh, $messages)) {
			$key = (string)$finished["handle"];
			$this->_responses[$key] = new WebResponse(curl_multi_getcontent($finished["handle"]), curl_getinfo($finished["handle"]));
			curl_multi_remove_handle($this->mh, $finished["handle"]);
		}
	}

private function store ( ) { while ( $ finished = curl_multi_info_read ( $ this -> mh , $ messages ) ) { $ key = ( string ) $ finished [ "handle" ] ; $ this -> _responses [ $ key ] = new WebResponse ( curl_multi_getcontent ( $ finished [ "handle" ] ) , curl_getinfo ( $ finished [ "handle" ] ) ) ; curl_multi_remove_handle ( $ this -> mh , $ finished [ "handle" ] ) ; } }

Runs through the request queue and processes completed requests
@access private


public function &getPlotData(&$bizObj, $fields, $labelField)
    {
        $oldCacheMode = $bizObj->GetCacheMode();
        $bizObj->SetCacheMode(0);    // turn off cache mode, not affect the current cache
        $bizObj->runSearch(-1);  // don't use page search
        while (1)
        {
            $recArray = $bizObj->GetRecord(1);
            if (!$recArray) break;
            $bizObj->UnformatInputRecArr($recArray);

            foreach($fields as $fld)
                $recMatrix[$fld][] = $recArray[$fld];   // get data without format
            $recMatrix[$labelField][] = $recArray[$labelField];   // get symbol with format
        }
        $bizObj->SetCacheMode($oldCacheMode);
        return $recMatrix;
    }

Get plot data array

@param BizObj $bizObj object reference of bizobj
@param array $fields list of bizobj fields
@param array $labelField label field of bizobj
@return array reference of the array [field][index]


public function renderXYPlot(&$data, &$xmlArr)
    {
        $id = $xmlArr['ATTRIBUTES']['ID'];
        $field = $xmlArr['ATTRIBUTES']['FIELD'];
        $chartType = $xmlArr['ATTRIBUTES']['CHARTTYPE'];
        $pointType = $xmlArr['ATTRIBUTES']['POINTTYPE'];
        $weight = $xmlArr['ATTRIBUTES']['WEIGHT'];
        $color = $xmlArr['ATTRIBUTES']['COLOR'];
        $fillColor = $xmlArr['ATTRIBUTES']['FILLCOLOR'];
        $showVal = $xmlArr['ATTRIBUTES']['SHOWVALUE'];
        $legend = $xmlArr['ATTRIBUTES']['LEGENDFIELD'];
        $visible = $xmlArr['ATTRIBUTES']['VISIBLE'];

        if ($chartType == 'Line' or $chartType == 'Bar')
        {
            if ($chartType == 'Line')
            {
                include_once (JPGRAPH_DIR.'/jpgraph_line.php');
                $plot = new LinePlot($data);
                $this->_drawMark($plot->mark,
                        $xmlArr['POINTMARK']['ATTRIBUTES']['TYPE'], $xmlArr['POINTMARK']['ATTRIBUTES']['COLOR'],
                        $xmlArr['POINTMARK']['ATTRIBUTES']['FILLCOLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['SIZE']);
                $plot->SetBarCenter();
                $plot->SetCenter();
            }
            else if ($chartType == 'Bar')
            {
                include_once (JPGRAPH_DIR.'/jpgraph_bar.php');
                $plot = new BarPlot($data);
                $plot->SetAlign('center');
            }
            if ($color) $plot->SetColor($color);
            if ($fillColor) $plot->SetFillColor($fillColor);
            if ($weight) $plot->SetWeight($weight);
            if ($showVal == 1) $plot->value->Show();
            if ($legend) $plot->SetLegend($legend);
            $this->_drawString($plot->value,$xmlArr['VALUE']['ATTRIBUTES']['FONT'],$xmlArr['VALUE']['ATTRIBUTES']['COLOR']);
        }

        if ($chartType == 'GroupBar' or $chartType == 'AccBar')
        {
            $children = $xmlArr['ATTRIBUTES']['CHILDREN'];
            $childList = explode(",",$children);
            foreach($childList as $child)
            {
                $childPlotList[] = $this->plotList[$child];
            }
            if ($chartType == 'GroupBar')
                $plot = new GroupBarPlot($childPlotList);
            else if ($chartType == 'AccBar')
                $plot = new AccBarPlot($childPlotList);
        }

        $this->plotList[$id] = $plot;

        if ($visible == 1)
            return $plot;
        return null;
    }

public function renderXYPlot ( & $ data , & $ xmlArr ) { $ id = $ xmlArr [ 'ATTRIBUTES' ] [ 'ID' ] ; $ field = $ xmlArr [ 'ATTRIBUTES' ] [ 'FIELD' ] ; $ chartType = $ xmlArr [ 'ATTRIBUTES' ] [ 'CHARTTYPE' ] ; $ pointType = $ xmlArr [ 'ATTRIBUTES' ] [ 'POINTTYPE' ] ; $ weight = $ xmlArr [ 'ATTRIBUTES' ] [ 'WEIGHT' ] ; $ color = $ xmlArr [ 'ATTRIBUTES' ] [ 'COLOR' ] ; $ fillColor = $ xmlArr [ 'ATTRIBUTES' ] [ 'FILLCOLOR' ] ; $ showVal = $ xmlArr [ 'ATTRIBUTES' ] [ 'SHOWVALUE' ] ; $ legend = $ xmlArr [ 'ATTRIBUTES' ] [ 'LEGENDFIELD' ] ; $ visible = $ xmlArr [ 'ATTRIBUTES' ] [ 'VISIBLE' ] ; if ( $ chartType == 'Line' or $ chartType == 'Bar' ) { if ( $ chartType == 'Line' ) { include_once ( JPGRAPH_DIR . '/jpgraph_line.php' ) ; $ plot = new LinePlot ( $ data ) ; $ this -> _drawMark ( $ plot -> mark , $ xmlArr [ 'POINTMARK' ] [ 'ATTRIBUTES' ] [ 'TYPE' ] , $ xmlArr [ 'POINTMARK' ] [ 'ATTRIBUTES' ] [ 'COLOR' ] , $ xmlArr [ 'POINTMARK' ] [ 'ATTRIBUTES' ] [ 'FILLCOLOR' ] , $ xmlArr [ 'POINTMARK' ] [ 'ATTRIBUTES' ] [ 'SIZE' ] ) ; $ plot -> SetBarCenter ( ) ; $ plot -> SetCenter ( ) ; } else if ( $ chartType == 'Bar' ) { include_once ( JPGRAPH_DIR . '/jpgraph_bar.php' ) ; $ plot = new BarPlot ( $ data ) ; $ plot -> SetAlign ( 'center' ) ; } if ( $ color ) $ plot -> SetColor ( $ color ) ; if ( $ fillColor ) $ plot -> SetFillColor ( $ fillColor ) ; if ( $ weight ) $ plot -> SetWeight ( $ weight ) ; if ( $ showVal == 1 ) $ plot -> value -> Show ( ) ; if ( $ legend ) $ plot -> SetLegend ( $ legend ) ; $ this -> _drawString ( $ plot -> value , $ xmlArr [ 'VALUE' ] [ 'ATTRIBUTES' ] [ 'FONT' ] , $ xmlArr [ 'VALUE' ] [ 'ATTRIBUTES' ] [ 'COLOR' ] ) ; } if ( $ chartType == 'GroupBar' or $ chartType == 'AccBar' ) { $ children = $ xmlArr [ 'ATTRIBUTES' ] [ 'CHILDREN' ] ; $ childList = explode ( "," , $ children ) ; foreach ( $ childList as $ child ) { $ childPlotList [ ] = $ this -> plotList [ $ child ] ; } if ( $ chartType == 'GroupBar' ) $ plot = new GroupBarPlot ( $ childPlotList ) ; else if ( $ chartType == 'AccBar' ) $ plot = new AccBarPlot ( $ childPlotList ) ; } $ this -> plotList [ $ id ] = $ plot ; if ( $ visible == 1 ) return $ plot ; return null ; }

Draw the XY type plot

@param array $data plot data array reference
@param array $xmlArr xml array reference
@return object refernce XY plot object reference


private function _getMark($mark)
    {
        switch (strtoupper($mark))
        {
            case "SQUARE": return MARK_SQUARE;
            case "UTRIANGLE": return MARK_UTRIANGLE;
            case "DTRIANGLE": return MARK_DTRIANGLE;
            case "DIAMOND": return MARK_DIAMOND;
            case "CIRCLE": return MARK_CIRCLE;
            case "FILLEDCIRCLE": return MARK_FILLEDCIRCLE;
            case "CROSS": return MARK_CROSS;
            case "STAR": return MARK_STAR;
            case "X": return MARK_X;
            default: return 0;
        }
    }

private function _getMark ( $ mark ) { switch ( strtoupper ( $ mark ) ) { case "SQUARE" : return MARK_SQUARE ; case "UTRIANGLE" : return MARK_UTRIANGLE ; case "DTRIANGLE" : return MARK_DTRIANGLE ; case "DIAMOND" : return MARK_DIAMOND ; case "CIRCLE" : return MARK_CIRCLE ; case "FILLEDCIRCLE" : return MARK_FILLEDCIRCLE ; case "CROSS" : return MARK_CROSS ; case "STAR" : return MARK_STAR ; case "X" : return MARK_X ; default : return 0 ; } }

Get the point make number

@param string $mark point mark string
@access private
@return integer mark number


private function _getFont($font)
    {
        switch (strtoupper($font))
        {
            case "ARIAL": return FF_ARIAL;
            case "COURIER;": return FF_COURIER;
            case "TIMES": return FF_TIMES;
            case "VERDANA": return FF_VERDANA;
            case "COMIC": return FF_COMIC;
            case "GEORGIA": return FF_GEORGIA;
            default: return FF_FONT1;
        }
    }

private function _getFont ( $ font ) { switch ( strtoupper ( $ font ) ) { case "ARIAL" : return FF_ARIAL ; case "COURIER;" : return FF_COURIER ; case "TIMES" : return FF_TIMES ; case "VERDANA" : return FF_VERDANA ; case "COMIC" : return FF_COMIC ; case "GEORGIA" : return FF_GEORGIA ; default : return FF_FONT1 ; } }

Get the font number

@param string $font font string
@access private
@return integer font number


public static function Instance($token = null, $config = array())
    {
        if (self::$instance == null || !empty($token)) {
            self::$instance = new self($token, $config);
        }
        return self::$instance;
    }

public static function Instance ( $ token = null , $ config = array ( ) ) { if ( self :: $ instance == null || ! empty ( $ token ) ) { self :: $ instance = new self ( $ token , $ config ) ; } return self :: $ instance ; }

I AM SINGLETON
We don't need to go instantiating all these objects more than once here
@return Instaphp

I AM SINGLETON We don t need to go instantiating all these objects more than once here


public function getAttribute($key)
    {
        if (isset($this->attributes[$key])) {
            return $this->attributes[$key];
        }

        return null;
    }

public function getAttribute ( $ key ) { if ( isset ( $ this -> attributes [ $ key ] ) ) { return $ this -> attributes [ $ key ] ; } return null ; }

Get attribute by key

@param string $group

@return array


public function setAttributeInGroup($group, $key, $value)
    {
        $this->attributes[$group][$key] = $value;

        return $this;
    }

public function setAttributeInGroup ( $ group , $ key , $ value ) { $ this -> attributes [ $ group ] [ $ key ] = $ value ; return $ this ; }

Set attributes by group and key

@param string $group
@param string $key
@param array $attributes

@return self


public function getAttributeInGroup($group, $key)
    {
        if (isset($this->attributes[$group][$key])) {
            return $this->attributes[$group][$key];
        }

        return null;
    }

public function getAttributeInGroup ( $ group , $ key ) { if ( isset ( $ this -> attributes [ $ group ] [ $ key ] ) ) { return $ this -> attributes [ $ group ] [ $ key ] ; } return null ; }

Get attribute by group and key. It will return null if doesn't exists

@param array $group
@param string $key

@return string|null

Get attribute by group and key . It will return null if doesn t exists


public function findOrCreate($id, array $columns = ['*'])
    {
        $model = $this->query()->find($id, $columns);
        if (!$model) {
            return $this->getModel()->newInstance();
        }

        return $model;
    }

public function findOrCreate ( $ id , array $ columns = [ '*' ] ) { $ model = $ this -> query ( ) -> find ( $ id , $ columns ) ; if ( ! $ model ) { return $ this -> getModel ( ) -> newInstance ( ) ; } return $ model ; }

Find a model by its primary key. If not then ne instance is being created.

@param int $id
@param array $columns
@return Model

Find a model by its primary key . If not then ne instance is being created .


public function getModel()
    {
        if (!$this->hasDependency('model') && !$this->model instanceof Model) {
            throw new Exceptions\NoModelSetException;
        }

        return $this->model;
    }

public function getModel ( ) { if ( ! $ this -> hasDependency ( 'model' ) && ! $ this -> model instanceof Model ) { throw new Exceptions \ NoModelSetException ; } return $ this -> model ; }

Get repository model's instance.

@return Model

@throws Exceptions\NoModelSetException


private function uniqueId($hookName, $function, $priority)
    {
        static $count = 0;
        if (is_string($function)) {
            return $function;
        }
        if (is_object($function)) {
            // Closures are currently implemented as objects
            $function = array($function, '');
        } elseif (!is_array($function)) {
            $function = array($function);
        }

        if (is_object($function[0])) {
            // Object Class Calling
            if (function_exists('spl_object_hash')) {
                return spl_object_hash($function[0]) . $function[1];
            } else {
                $object_id = get_class($function[0]).$function[1];
                if (!isset($function[0]->id)) {
                    if (false === $priority) {
                        return false;
                    }
                    $object_id .= isset($this->filters[$hookName][$priority])
                        ? count((array) $this->filters[$hookName][$priority])
                        : $count;
                    $function[0]->id = $count;
                    $count++;
                } else {
                    $object_id .= $function[0]->id;
                }
                return $object_id;
            }
        } elseif (is_string($function[0])) {
            // callas static
            return $function[0] . '::' . $function[1];
        }
        // unexpected result
        return null;
    }

Create Unique ID if function is not string

@param string   $hookName determine the hook name
@param callable $function function to call
@param integer  $priority the priority of hooks

@access private
@return string|bool