public function addAction()
 {
     // TODO Auto-generated ChannelController::indexAction() default action
     $arUser = $this->authenticate();
     if (!$this->_request->isPost()) {
         return;
     }
     $channels = new Channels();
     $channelID = $channels->addChannel($this->getRequest()->getParam('title'), $arUser['id']);
     if ($channelID !== false) {
         $this->_helper->redirector->goto('add', 'item', null, array('channel_id' => $channelID));
     }
 }
Example #2
0
 /**
  * Model definition.
  */
 function define()
 {
     // Fields.
     $this->fields = array('id', 'slug', 'name', 'fields', 'inputs', 'subscribers', 'date_created', 'date_updated', 'fields' => function ($channel) {
         return orderby($channel['fields'], 'sort');
     }, 'fields_by_id' => function ($channel) {
         return Channels::get_fields_by_id($channel);
     }, 'entries' => function ($channel) {
         return get("/entries", array('channel_id' => $channel['id']));
     }, 'entry_count' => function ($channel) {
         return get("/entries/:count", array('channel_id' => $channel['id']));
     });
     $this->search_fields = array('name');
     // Indexes.
     $this->indexes = array('id' => 'unique', 'slug' => 'unique');
     // Query defaults.
     $this->query = array('order' => 'name ASC');
     // Validate.
     $this->validate = array('required' => array('name', 'slug'), 'unique' => array('slug'), ':fields' => array('required' => array('id', 'name', 'type'), 'unique' => array('id')));
     // Event binds.
     $this->binds = array('POST' => function ($event) {
         $data =& $event['data'];
         // Auto slug?
         if ($data['name'] && !$data['slug']) {
             $data['slug'] = hyphenate($data['name']);
         }
     }, 'POST.fields' => function ($event) {
         $data =& $event['data'];
         // Default field ID to underscored field name.
         if (isset($data['name']) && !$data['id']) {
             $data['id'] = underscore($data['name']);
         }
     });
 }
Example #3
0
 /**
  * @test
  */
 public function shouldGetAllTheAssignedChannels()
 {
     $channels = Channels::createWaiting(5);
     foreach ($channels->getWaitingChannels() as $channel) {
         $process = $this->getMockBuilder('\\Liuggio\\Spawn\\Process\\Process')->disableOriginalConstructor()->getMock();
         $channels->assignAProcess($channel, $process);
     }
     $this->assertCount(5, $channels->getAssignedChannels());
     $this->assertCount(0, $channels->getWaitingChannels());
 }
Example #4
0
 public function edit($phone, $addate, $id)
 {
     $bean = Channels::i($id);
     if ($bean->user_name) {
         $bean->ip = $ip;
         $bean->localip = $localip;
         $flag = $bean->save();
     }
     return $flag;
 }
Example #5
0
 /**
  * 功能号:2060
  * 设置Ping命令
  * */
 public function set_pinginfo()
 {
     COMFilter::$_jump = false;
     $code = Core::$_dataFilter->valueCheck(Core::get("code"), "Require,Limit", "code不能为空,code非法", false, 13);
     $pingstr = Core::$_dataFilter->valueCheck(Core::get("ping"), "Require", "ping不能为空");
     if (!Core::checkcode($code)) {
         Core::json_error('code 不合法');
     }
     bChannel_ping::delete();
     $flag = false;
     $addate = time();
     $channel = Channels::getOne("code = ?", array($code));
     if ($channel) {
         $pingstr = str_replace("\n", '<br/>', $pingstr);
         if (bChannel_ping::addChannel_ping($code, $pingstr, $addate)) {
             $flag = true;
             $mess = "添加信息成功";
         } else {
             $mess = "添加信息失败";
         }
     } else {
         $mess = "频道不存在";
     }
     if ($flag) {
         Core::json_result('', $mess);
     } else {
         Core::json_error($mess);
     }
 }
Example #6
0
 public static function addChannels($chans)
 {
     foreach ($chans as $chan) {
         Channels::addChannel($chan);
     }
 }
 public function actionChannel()
 {
     $todo = array();
     $filename = './public/channel.txt';
     $result = file($filename);
     $result = array_map('check', $result);
     $specialChar = ':';
     $pid = 0;
     $i = 1;
     foreach ($result as $item) {
         $todo[$i]['name'] = str_replace($specialChar, '', $item);
         $todo[$i]['id'] = $i;
         $todo[$i]['weight'] = rand(1, 9);
         $todo[$i]['description'] = '此频道提供' . $todo[$i]['name'] . '相关信息';
         $todo[$i]['charge'] = 1;
         $todo[$i]['uid'] = 1;
         if (strpos($item, $specialChar)) {
             $todo[$i]['pid'] = 0;
             $pid = $i;
         } else {
             $todo[$i]['pid'] = $pid;
         }
         $i++;
     }
     foreach ($todo as $item) {
         $channels = new Channels();
         $channels->id = $item['id'];
         $channels->name = $item['name'];
         $channels->weight = $item['weight'];
         $channels->description = $item['description'];
         $channels->charge = $item['charge'];
         $channels->uid = $item['uid'];
         $channels->pid = $item['pid'];
         if ($channels->save()) {
             echo 'ok' . $channels->id . "<br />";
         } else {
             echo CHtml::errorSummary($channels);
         }
     }
     UtilHelper::dump($todo);
 }