Esempio n. 1
0
 public function get($channel, $strict = true)
 {
     $exists = $this->exists($channel, $strict);
     if (!$exists) {
         throw new Exception('Channel ' . $channel . ' does not exist');
     }
     if (1 === $exists) {
         // is a default channel not installed
         return $this->getDefaultChannel($channel);
     }
     $channel = $this->channelFromAlias($channel);
     $cont = file_get_contents($this->channelFileName($channel));
     $a = @unserialize($cont);
     if (!$a || !is_array($a)) {
         throw new Exception('Channel ' . $channel . ' PEAR1 registry file is corrupt');
     }
     try {
         $chan = new Channel($this, $a);
         if ($channel != '__uri') {
             $chan->validate();
         }
         return $chan;
     } catch (\Exception $e) {
         throw new Exception('Channel ' . $channel . ' PEAR1 registry file is invalid channel information', $e);
     }
 }
Esempio n. 2
0
 public function AddChannelToPoint($pointId)
 {
     $_pointId = $pointId;
     $model = new Channel();
     $res = Channel::model()->findAll('id_point=:id_point ORDER BY internalId ASC', array(':id_point' => $_pointId));
     $internalId = 1;
     if (count($res) > 0) {
         $internalId = $res[count($res) - 1]['internalId'] + 1;
     }
     $model->attributes = array('id_point' => $_pointId, 'internalId' => $internalId);
     if ($model->validate() && $model->save()) {
         $id = $model->getPrimaryKey();
         return array("status" => true, "id" => $id, "internalId" => $internalId);
     } else {
         return array("status" => false, "error" => json_encode($model->getErrors()));
     }
 }