public function render()
 {
     $value = 0;
     $value_id = 0;
     $aDataSource = $this->getDataSource();
     $aDataSource[2]['Criteria']['ParentId'] = 0;
     $oDataProvider = new DataProvider($aDataSource);
     $oData = $oDataProvider->execute();
     //echo '<pre>', print_r($oData, true), '</pre>'; die();
     $aResult = array();
     $aResult[] = array('Name' => $this->getDefaultText(), 'Value' => $this->getDefaultValue());
     if ($this->getDefault()) {
         $aRs = array();
         if (preg_match("#:(.*?)#isU", $this->getDefault(), $aRs)) {
             $value = Toolkit::getInstance()->request->get($aRs[1], Request::C_GET);
         }
     }
     if ($this->getValue()) {
         $value_id = $this->getValue();
     }
     if ($oData->count() > 0) {
         $aResult = $this->getChilds($oData, 1, $aResult);
     }
     echo FormHelper::selectbox($this->getAlias(), $value_id, $aResult, array('class' => 'selectbox', 'id' => 'field_' . $this->getAlias()));
 }
 public function render()
 {
     $value = 0;
     $value_id = 0;
     $oDataProvider = new DataProvider($this->getDataSource());
     $oData = $oDataProvider->execute();
     //echo '<pre>', print_r($oData, true), '</pre>'; die();
     $aResult = array();
     /*$aResult[] = array(
           'Name' => $this->getDefaultText(),
           'Value' => $this->getDefaultValue()
       ); */
     if ($this->getDefault()) {
         $aRs = array();
         if (preg_match("#:(.*?)#isU", $this->getDefault(), $aRs)) {
             $value = Toolkit::getInstance()->request->get($aRs[1], Request::C_GET);
         }
     }
     //echo 'val:', print_r($this->getValue()->toSimpleArray(), true);
     if ($this->getValue()) {
         $value_id = $this->getValue()->toSimpleArray();
     }
     if ($oData->count() > 0) {
         foreach ($oData as $itm) {
             $getter = 'get' . $this->getValueField();
             $aResultTmp = array('Value' => call_user_func(array($itm, $getter)), 'Name' => $this->getTextFormat());
             $aRs = array();
             if (preg_match_all("/:(.*):/iU", $aResultTmp['Name'], $aRs)) {
                 foreach ($aRs[1] as $k => $val) {
                     $value = $itm;
                     if (strpos($val, "-") !== false) {
                         $xVal = explode("-", $val);
                         foreach ($xVal as $_val) {
                             $sGetter = 'get' . $_val;
                             $value = call_user_func(array($value, $sGetter));
                         }
                     } else {
                         $sGetter = 'get' . $val;
                         $value = call_user_func(array($value, $sGetter));
                     }
                     $aResultTmp['Name'] = str_replace($aRs[0][$k], $value, $aResultTmp['Name']);
                 }
             }
             /*if (isset($aContainer['IsTree']) && $aContainer['IsTree'] == true) {
             			$aResultTmp['Name'] = str_repeat(' |-- ', $itm->getTreeLevel() - 1).$aResultTmp['Name'];
             		}*/
             $aResult[] = $aResultTmp;
         }
     }
     $sResult = FormHelper::multiselect($this->getAlias() . '[]', $value_id, $aResult, array('class' => 'multiselect', 'id' => 'field_' . $this->getAlias()));
     if ($this->getExtended()) {
         $sResult .= '<script>$(document).ready(
             function()
             {
                 $(\'#field_' . $this->getAlias() . '\').multiselect({sortable: false, searchable: false});
             }
         );</script>';
     }
     echo $sResult;
 }
 public function render()
 {
     $value = 0;
     $value_id = 0;
     $aDataSource = $this->getDataSource();
     if ($this->getIsTree()) {
         $aDataSource[2]['Criteria']['ParentId'] = 0;
     }
     $oDataProvider = new DataProvider($aDataSource);
     $oData = $oDataProvider->execute();
     //echo '<pre>', print_r($oData, true), '</pre>'; die();
     $aResult = array();
     $aResult[] = array('Name' => $this->getDefaultText(), 'Value' => $this->getDefaultValue());
     if ($this->getDefault()) {
         $aRs = array();
         if (preg_match("#:(.*?)#isU", $this->getDefault(), $aRs)) {
             $value = Toolkit::getInstance()->request->get($aRs[1], Request::C_GET);
         }
     }
     if ($this->getValue()) {
         $value_id = $this->getValue();
     }
     $aResult = $this->createRow($oData, $aResult);
     if ($this->getOnChange()) {
         $tmpChange = $this->getOnChange();
         echo FormHelper::selectbox($this->getAlias(), $value_id, $aResult, array('class' => 'selectbox ajax_response_list', 'data-field' => $tmpChange[0], 'data-id' => $this->getValue(), 'id' => 'field_' . $this->getAlias()));
         //$.post('/structure/page_backend/typeParams', {Id: $this->getValue()}, function (data) { /* response */ });
     } else {
         echo FormHelper::selectbox($this->getAlias(), $value_id, $aResult, array('class' => 'selectbox', 'id' => 'field_' . $this->getAlias()));
     }
 }
Beispiel #4
0
 /**
  * Get all devices
  */
 public function fetchAll()
 {
     $devices = json_decode($this->dataProvider->get('devices')->getBody()->__toString());
     foreach ($devices->devices as $deviceData) {
         $device = new Device($deviceData, $this->dataProvider);
         $this->devices[$device->getId()] = $device;
     }
 }
Beispiel #5
0
 function test_calc_step_division_by_zero()
 {
     $term = new stdClass();
     $term->term_id = 1;
     $term->count = 1;
     $terms = array($term, $term);
     $data = $this->dataProvider->get_data_object(array(), $terms);
     $data->getTerms();
 }
Beispiel #6
0
 /**
  * @param int $hostuid
  * @return FtpUserModel|null
  */
 public function getFtpUserByUid($hostuid)
 {
     $result = $this->dataProvider->findFtpUserByHostUid($hostuid);
     if (!$result) {
         return null;
     }
     $ftpUser = $this->dataProvider->createFtpUserFromResult($result);
     return $ftpUser;
 }
Beispiel #7
0
 function execute($par)
 {
     global $wgOut;
     $this->setHeaders();
     $topFiveArray = DataProvider::GetTopFiveArray();
     if (empty($par)) {
         //no sub gets generic title
         $wgOut->setPageTitle("Top");
         //use array keys of known modules to build menu to them
         $wgOut->addHtml("<ul>");
         foreach ($topFiveArray[0] as $sub => $junk) {
             $wgOut->addHtml("<li><a href=\"" . SpecialPage::getTitleFor('Top', $sub)->getLocalUrl() . "\">" . wfMsg($sub) . "</a></li>");
         }
         $wgOut->addHtml("</ul>");
         return false;
     }
     if (count($topFiveArray) != 2 || !isset($topFiveArray[0][$par])) {
         $wgOut->setPageTitle("Error");
         // par wasnt in known module list, so cant use for title
         return false;
     }
     //we can trust par for use in title now
     $wgOut->setPageTitle(wfMsg($par));
     $wgOut->addHtml("<ul>");
     $results = DataProvider::$topFiveArray[0][$par](25);
     if (is_array($results)) {
         foreach ($results as $val) {
             $wgOut->addHtml("<li><a href=\"{$val['url']}\">{$val['text']}</a></li>");
         }
     }
     $wgOut->addHtml("</ul>");
 }
Beispiel #8
0
 /**
  * Handle incoming SMS from Twilio
  */
 public function action_reply()
 {
     //Check if data provider is available
     $providers_available = Kohana::$config->load('features.data-providers');
     if (!$providers_available['twilio']) {
         throw HTTP_Exception::factory(403, 'The Twilio data source is not currently available. It can be accessed by upgrading to a higher Ushahidi tier.');
     }
     if ($this->request->method() != 'POST') {
         // Only POST is allowed
         throw HTTP_Exception::factory(405, 'The :method method is not supported. Supported methods are :allowed_methods', array(':method' => $this->request->method(), ':allowed_methods' => Http_Request::POST))->allowed(Http_Request::POST);
     }
     $provider = DataProvider::factory('twilio');
     // Authenticate the request
     $options = $provider->options();
     if ($this->request->post('AccountSid') !== $options['account_sid']) {
         throw HTTP_Exception::factory(403, 'Incorrect or missing AccountSid');
     }
     // Remove Non-Numeric characters because that's what the DB has
     $to = preg_replace("/[^0-9,.]/", "", $this->request->post('To'));
     $from = preg_replace("/[^0-9,.]/", "", $this->request->post('From'));
     $message_text = $this->request->post('Body');
     $message_sid = $this->request->post('MessageSid');
     // @todo use other info from twillio, ie: location, media
     $provider->receive(Message_Type::SMS, $from, $message_text, $to, NULL, $message_sid);
     // If we have an auto response configured, return the response messages
     if (!empty($options['sms_auto_response'])) {
         $body = View::factory('twillio/sms_response')->set('response', $options['sms_auto_response'])->render();
         // Set the correct content-type header
         $this->response->headers('Content-Type', 'text/xml');
         $this->response->body($body);
     }
 }
Beispiel #9
0
 public function action_index()
 {
     // Set up custom error view
     Kohana_Exception::$error_view = 'error/data-provider';
     if ($this->request->method() != 'GET') {
         // Only GET is allowed as FrontlineSms does only GET request
         throw HTTP_Exception::factory(405, 'The :method method is not supported. Supported methods are :allowed_methods', array(':method' => $this->request->method(), ':allowed_methods' => Http_Request::GET))->allowed(Http_Request::GET);
     }
     $provider = DataProvider::factory('frontlinesms');
     // Authenticate the request
     $options = $provider->options();
     if (!isset($options['key']) or empty($options['key'])) {
         throw HTTP_Exception::factory(403, 'Key value has not been configured');
     }
     if (!$this->request->query('key') or $this->request->query('key') != $options['key']) {
         throw HTTP_Exception::factory(403, 'Incorrect or missing key');
     }
     if (!$this->request->query('m')) {
         throw HTTP_Exception::factory(403, 'Missing message');
     }
     // Remove Non-Numeric characters because that's what the DB has
     $from = preg_replace('/\\D+/', "", $this->request->post('from'));
     $message_text = $this->request->query('m');
     // If receiving an SMS Message
     if ($from and $message_text) {
         $provider->receive(Message_Type::SMS, $from, $message_text, $to);
     }
     $json = array('payload' => array('success' => TRUE, 'error' => NULL));
     // Set the correct content-type header
     $this->response->headers('Content-Type', 'application/json');
     $this->response->body(json_encode($json));
 }
Beispiel #10
0
 public function action_index()
 {
     // Set up custom error view
     Kohana_Exception::$error_view = 'error/data-provider';
     //Check if data provider is available
     $providers_available = Kohana::$config->load('features.data-providers');
     if (!$providers_available['smssync']) {
         throw HTTP_Exception::factory(403, 'The SMS Sync data source is not currently available. It can be accessed by upgrading to a higher Ushahidi tier.');
     }
     $methods_with_http_request = [Http_Request::POST, Http_Request::GET];
     if (!in_array($this->request->method(), $methods_with_http_request)) {
         // Only POST or GET is allowed
         throw HTTP_Exception::factory(405, 'The :method method is not supported. Supported methods are :allowed_methods', array(':method' => $this->request->method(), ':allowed_methods' => implode(',', $methods_with_http_request)))->allowed($methods_with_http_request);
     }
     $this->_provider = DataProvider::factory('smssync');
     $this->options = $this->_provider->options();
     // Ensure we're always returning a payload..
     // This will be overwritten later if incoming or task methods are run
     $this->_json['payload'] = ['success' => TRUE, 'error' => NULL];
     // Process incoming messages from SMSSync only if the request is POST
     if ($this->request->method() == 'POST') {
         $this->_incoming();
     }
     // Attempt Task if request is GET and task type is 'send'
     if ($this->request->method() == 'GET' and $this->request->query('task') == 'send') {
         $this->_task();
     }
     // Set the response
     $this->_set_response();
 }
Beispiel #11
0
 /**
  * Callback for 'gather' response on call to Twilio
  */
 public function action_gather()
 {
     if ($this->request->method() != 'POST') {
         // Only POST is allowed
         throw HTTP_Exception::factory(405, 'The :method method is not supported. Supported methods are :allowed_methods', array(':method' => $this->request->method(), ':allowed_methods' => Http_Request::POST))->allowed(Http_Request::POST);
     }
     $provider = DataProvider::factory('twilio');
     // Authenticate the request
     $options = $provider->options();
     if ($this->request->post('AccountSid') !== $options['account_sid']) {
         // Could not authenticate the request?
         throw HTTP_Exception::factory(403, 'Incorrect or missing AccountSid');
     }
     // Remove Non-Numeric characters because that's what the DB has
     $to = preg_replace("/[^0-9,.]/", "", $this->request->post('To'));
     $from = preg_replace("/[^0-9,.]/", "", $this->request->post('From'));
     $message_sid = $this->request->post('CallSid');
     $digits = $this->request->post('Digits');
     if ($digits == 1) {
         $message_text = 'IVR: Okay';
     } else {
         if ($digits == 2) {
             $message_text = 'IVR: Not Okay';
         } else {
             // HALT
             Kohana::$log->add(Log::ERROR, __("':digits' is not a valid IVR response", array(":digits" => $digits)));
             return;
         }
     }
     $provider->receive(Message_Type::IVR, $from, $message_text, $to, NULL, $message_sid);
 }
 function CheckLoginInDB($username, $password)
 {
     if (empty($username) || empty($password)) {
         $this->HandleError("Tên đăng nhập / Mật khẩu không được để trống");
         return -1;
     } else {
         //$password = md5($password);
         //$connection = mysqli_connect("localhost","root","","tapdoc");
         //$query  = mysqli_query($connection, "SELECT * FROM taikhoan WHERE tk_TenDangNhap='$username' AND tk_MatKhau = '$password'");
         $sql = "SELECT * FROM taikhoan WHERE tk_TenDangNhap='{$username}' AND tk_MatKhau = '{$password}'";
         $query = DataProvider::ExecuteQuery($sql);
         $rows = mysqli_num_rows($query);
         if ($rows == 1) {
             $id = -1;
             while ($row = $query->fetch_assoc()) {
                 $id = $row["tk_ID"];
             }
             //mysqli_close($connection);
             return $id;
         } else {
             $this->HandleError("Tên đăng nhập / Mật khẩu không hợp lệ");
         }
         //mysqli_close($connection);
     }
 }
Beispiel #13
0
 /**
  * User constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->name = "";
     $this->table = ARCDBPREFIX . "companies";
     $this->map = ["id" => "id", "name" => "name"];
     $this->columns = ["id", "name"];
 }
Beispiel #14
0
function WidgetTopContentGetSectionsList()
{
    wfProfileIn(__METHOD__);
    $provider =& DataProvider::singleton();
    list($links, $active) = $provider->GetTopFiveArray();
    unset($links['community']);
    wfProfileOut(__METHOD__);
    return array(0 => $links, 1 => $active);
}
 public static function delete($id)
 {
     $strSQL = "delete from thuchi where id={$id}";
     $result = DataProvider::Query($strSQL);
     if (mysql_affected_rows() == 0) {
         return null;
     }
     return mysql_fetch_row($result, MYSQL_BOTH);
 }
 public static function GetPhapLyById($id)
 {
     $strSQL = "select *\r\n\t\t\t\t\tfrom tinhtrangphaply where id='{$id}'";
     $result = DataProvider::Query($strSQL);
     if (mysql_num_rows($result) == 0) {
         return null;
     }
     return mysql_fetch_array($result);
 }
 public static function getALL()
 {
     $strSQL = "select * from loaidichvu";
     $result = DataProvider::Query($strSQL);
     while ($row = mysql_fetch_row($result, MYSQL_BOTH)) {
         $return[] = $row;
     }
     return $return;
 }
 public static function GetTTNDByID($id)
 {
     $strSQL = "select * \r\n\t\t\t\t\t   from loaidichvu\r\n\t\t\t\t\t   where id='{$id}'";
     $result = DataProvider::Query($strSQL);
     if (mysql_num_rows($result) == 0) {
         return null;
     }
     return mysql_fetch_array($result);
 }
 public static function GetAllTienIchId($id)
 {
     $strSQL = "select *\r\n\t\t\t\t\t   from tienich where id='{$id}'";
     $result = DataProvider::Query($strSQL);
     if (mysql_num_rows($result) == 0) {
         return null;
     }
     return mysql_fetch_array($result);
 }
Beispiel #20
0
 /**
  * UserPermission constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->groupid = 0;
     $this->permission = "";
     $this->table = ARCDBPREFIX . 'user_permissions';
     $this->map = ["id" => "id", "groupid" => "groupid", "permission" => "permission"];
     $this->columns = ['id', 'groupid', 'permission'];
 }
 public static function GetHuongNhaById($id)
 {
     $strSQL = "select *\r\n\t\t\t\t\tfrom huongnha where id='{$id}'";
     $result = DataProvider::Query($strSQL);
     if (mysql_num_rows($result) == 0) {
         return null;
     }
     return mysql_fetch_array($result);
 }
 public static function GetAll()
 {
     $strSQL = "\tselect * \r\n\t\t\t\t\t\tfrom user_role \t\t\t\t\r\n\t\t\t\t\t\t";
     $result = DataProvider::Query($strSQL);
     while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
         $return[] = $row;
     }
     return $return;
 }
Beispiel #23
0
 public function __construct()
 {
     parent::__construct();
     $this->event = date("y-m-d H:i:s");
     $this->message = "";
     $this->table = ARCDBPREFIX . 'logs';
     $this->map = ["id" => "id", "type" => "type", "module" => "module", "event" => "event", "message" => "message"];
     $this->columns = ['id', 'type', 'module', 'event', 'message'];
 }
 public static function selectId($id)
 {
     $strSQL = "select * from donvidichvu where id='{$id}'";
     $result = DataProvider::Query($strSQL);
     if (mysql_num_rows($result) == 0) {
         return null;
     }
     return mysql_fetch_row($result, MYSQL_BOTH);
 }
 /**
   @param $prefix String to help locate the $target
   Removes all entries from the CacheProvider.
 */
 public static function cleanCache($prefix = '')
 {
     foreach (DataProvider::getStudies() as $s) {
         $f = self::getPath($s, $prefix);
         if (file_exists($f)) {
             unlink($f);
         }
     }
 }
 public static function getTinhById($id)
 {
     $strSQL = "select *\r\n\t\t\t\t\tfrom tinh where id={$id}";
     $result = DataProvider::Query($strSQL);
     if (mysql_num_rows($result) == 0) {
         return null;
     }
     return mysql_fetch_row($result, MYSQL_BOTH);
 }
Beispiel #27
0
 /**
  * Get all enabled providers, with their configuration data.
  * @return Array
  */
 protected function getAllProviders($enabled = false)
 {
     if ($enabled) {
         // Returns all *enabled* providers.
         return \DataProvider::get_enabled_providers();
     } else {
         // Returns all providers, even if they are disabled.
         return \DataProvider::get_providers();
     }
 }
Beispiel #28
0
function WidgetNewPages($id, $params)
{
    wfProfileIn(__METHOD__);
    $items = array();
    if (class_exists('DataProvider')) {
        $items = DataProvider::singleton()->GetNewlyCreatedArticles();
    }
    wfProfileOut(__METHOD__);
    return count($items) > 0 ? WidgetFramework::wrapLinks($items) . WidgetFramework::moreLink(Title::newFromText('Newpages', NS_SPECIAL)->getLocalURL()) : wfMsg('widget-empty-list');
}
Beispiel #29
0
 protected function execute_outgoing(InputInterface $input, OutputInterface $output)
 {
     $providers = $this->get_providers($input, $output);
     $limit = $input->getOption('limit');
     $totals = [];
     foreach ($providers as $id => $provider) {
         $totals[] = ['Provider' => $provider->name, 'Total' => \DataProvider::process_pending_messages($limit, $id)];
     }
     return $totals;
 }
 public static function selectID($id)
 {
     $strSQL = "select * from gioithieu where id='{$id}'";
     $result = DataProvider::Query($strSQL);
     if (mysql_num_rows($result) == 0) {
         return null;
     }
     $row = mysql_fetch_row($result, MYSQL_BOTH);
     return $row;
 }