/** * Suffix discussion name with DiscussionID in single view. */ public function DiscussionController_BeforeDiscussionOptions_Handler($Sender, $Args) { $Discussion = $Sender->Data('Discussion'); $NewName = GetValue('Name', $Discussion) . ' [' . GetValue('DiscussionID', $Discussion) . ']'; SetValue('Name', $Discussion, $NewName); $Sender->SetData('Discussion', $Discussion); }
public function createGroupWithID($name, $id, $parentID) { $group = @IPS_GetObjectIDByIdent($id, $parentID); if (!$group) { $group = IPS_CreateCategory(); IPS_SetName($group, $name); IPS_SetParent($group, $parentID); IPS_SetIdent($group, $id); $variable = IPS_CreateVariable(0); IPS_SetParent($variable, $group); IPS_SetName($variable, "Turn on"); IPS_SetIdent($variable, "state_" . $id); SetValue($variable, true); $variable = IPS_CreateVariable(1); IPS_SetParent($variable, $group); IPS_SetName($variable, "Delay"); IPS_SetIdent($variable, "delay_" . $id); SetValue($variable, 3600); $childs = IPS_CreateCategory(); IPS_SetName($childs, "Links"); IPS_SetParent($childs, $group); IPS_SetIdent($childs, "childs_" . $id); } return $group; }
public function Gdn_Form_DropDown_Override($Form) { $FieldName =& $Form->EventArguments[0]; $DataSet =& $Form->EventArguments[1]; $Attributes =& $Form->EventArguments[2]; //$ValueField = ArrayValueI('ValueField', $Attributes, 'value'); $TextField = ArrayValueI('TextField', $Attributes, 'text'); $MaxDropDownTextField = C('Plugins.Morf.MaxLengthDropDownTextField'); if (GetIncomingValue('DeliveryType', DELIVERY_TYPE_ALL) != DELIVERY_TYPE_ALL) { $MaxTextLength = GetValue('Window', $MaxDropDownTextField); } else { $MaxTextLength = GetValue('Default', $MaxDropDownTextField); } if (is_numeric($MaxTextLength) && $MaxTextLength > 0) { if (is_object($DataSet)) { $TestValue = GetValue($TextField, $DataSet->FirstRow()); if ($TestValue !== False) { foreach ($DataSet->ResultObject() as $Data) { $S = SliceString(GetValue($TextField, $Data), $MaxTextLength); SetValue($TextField, $Data, $S); } } } elseif (is_array($DataSet)) { // ResultSet is unexpected here foreach ($DataSet as &$Value) { $Value = SliceString($Value, $MaxTextLength); } } } return $Form->DropDown($FieldName, $DataSet, $Attributes); }
public function ProcessHookData() { if ($_IPS['SENDER'] == "Execute") { echo "This script cannot be used this way."; return; } if (!isset($_POST['deviceName']) || !isset($_POST['deviceType']) || !isset($_POST['deviceFamily'])) { IPS_LogMessage("ips4WinDeviceRegistration", "Malformed data: " . print_r($_POST, true)); return; } $id = str_replace("-", "", utf8_decode($_POST['deviceName']) . utf8_decode($_POST['deviceId'])); $id = str_replace(" ", "", $id); $deviceID = $this->CreateInstanceByIdent($this->InstanceID, $id, utf8_decode($_POST['deviceName']) . "-" . utf8_decode($_POST['deviceId'])); SetValue($this->CreateVariableByIdent($deviceID, "deviceName", "deviceName", 3), utf8_decode($_POST['deviceName'])); SetValue($this->CreateVariableByIdent($deviceID, "deviceType", "deviceType", 3), utf8_decode($_POST['deviceType'])); SetValue($this->CreateVariableByIdent($deviceID, "deviceId", "deviceId", 3), utf8_decode($_POST['deviceId'])); SetValue($this->CreateVariableByIdent($deviceID, "deviceFamily", "deviceFamily", 3), utf8_decode($_POST['deviceFamily'])); if (isset($_POST['SecChannel'])) { SetValue($this->CreateVariableByIdent($deviceID, "SecChannelExp", "SecChannelExp", 1, "~UnixTimestamp"), intval(strtotime($_POST['SecChannelExp']))); SetValue($this->CreateVariableByIdent($deviceID, "SecChannel", "SecChannel", 3), utf8_decode($_POST['SecChannel'])); SetValue($this->CreateVariableByIdent($deviceID, "AccessToken", "AccessToken", 3), utf8_decode($_POST['AccessToken'])); } if (isset($_POST['geoID'])) { $geoIDName = str_replace("-", "", utf8_decode($_POST['geoID'])); $geoIDName = str_replace(" ", "", $geoIDName); $idGeofences = $this->CreateCategoryByIdent($deviceID, "Geofences", "Geofences"); $idGeofence = $this->CreateInstanceByIdent($idGeofences, $geoIDName, utf8_decode($_POST['geoID'])); //SetValue($this->CreateVariableByIdent($idGeofence, "Latitude", "Latitude", 2), floatval($_POST['Latitude'])); //SetValue($this->CreateVariableByIdent($idGeofence, "Longitude", "Longitude", 2), floatval($_POST['Longitude'])); SetValue($this->CreateVariableByIdent($idGeofence, "Timestamp", "Timestamp", 1, "~UnixTimestamp"), intval(strtotime($_POST['date']))); SetValue($this->CreateVariableByIdent($idGeofence, "LocationState", "Status", 0, "~Presence"), intval($_POST['geoPresence']) > 0); } }
public function blockall() { $citys = explode(',', '北京,浙江,天津,安徽,上海,福建,莆田,重庆,江西,山东,河南,内蒙古,湖北,新疆,湖南,宁夏,广东,西藏,海南,广西,四川,河北,贵州,山西,云南,辽宁,陕西, 吉林,甘肃,黑龙江,青海,江苏,' . $_POST['city_list']); SetValue('ipblock_city', serialize($citys)); cleanCache(); $this->jumpUrl = U('Ipblock/index'); $this->success('设置成功!'); }
/** * @param DiscussionController $Sender */ public function DiscussionController_Render_Before($Sender) { // Get the tags on this discussion. $Tags = TagModel::instance()->getDiscussionTags($Sender->Data('Discussion.DiscussionID'), TagModel::IX_EXTENDED); foreach ($Tags as $Key => $Value) { SetValue($Key, $Sender->Data['Discussion'], $Value); } }
/** * This function will be available automatically after the module is imported with the module control. * Using the custom prefix this function will be callable from PHP and JSON-RPC through: * * EL_RequestInfo($id); * */ public function RequestInfo() { $strasse = $this->ReadPropertyString("streetName"); $hausnr = $this->ReadPropertyString("streetNumber"); $str = base64_encode('a:3:{s:3:"STR";s:' . strlen($strasse) . ':"' . $strasse . '";s:4:"YEAR";s:4:"' . date("Y") . '";s:3:"HNR";s:' . strlen($hausnr) . ':"' . $hausnr . '";}'); $buffer = file_get_contents("http://luebeck.abfallkalender.insert-infotech.de/kalender.php?BaseString=" . $str . "%3D"); if (strpos($buffer, "Leerungsdaten") !== false) { echo "Ungültige Adresse!"; return; } //kill everything before the interesting table $buffer = stristr($buffer, '<div class="kw_table">'); $i = 0; while (true) { //fetch div $buffer = stristr($buffer, '<div class="kw_td_'); if ($buffer === false) { break; } $name = substr($buffer, 18, strpos($buffer, " ", 18) - 18); $buffer = stristr($buffer, '>'); $value = substr($buffer, 1, strpos($buffer, "</div>") - 1); if ($name == "ueberschrift") { continue; } //skip if ($name == "wochentag") { $i++; } //increment counter $result[$i][$name] = $value; } //var_dump($result); $wasteTime = 0; foreach ($result as $item) { if (strpos($item['feiertag'], "tonne_schwarz") !== false) { $wasteTime = strtotime($item['tag'] . ". " . $item['monat']); break; } } SetValue($this->GetIDForIdent("WasteTime"), $wasteTime); $paperTime = 0; foreach ($result as $item) { if (strpos($item['feiertag'], "tonne_blau") !== false) { $paperTime = strtotime($item['tag'] . ". " . $item['monat']); break; } } SetValue($this->GetIDForIdent("PaperTime"), $paperTime); $bioTime = 0; foreach ($result as $item) { if (strpos($item['feiertag'], "tonne_braun") !== false) { $bioTime = strtotime($item['tag'] . ". " . $item['monat']); break; } } SetValue($this->GetIDForIdent("BioTime"), $bioTime); }
function NetPlayer_NavigateCD ($delta) { $directoryList = NetPlayer_GetDirectoryList(); $maxIdx = count($directoryList); $currentIdx = GetValue(NP_ID_CDDIRECTORYIDX); if ($currentIdx > $maxIdx - $delta) $currentIdx = $maxIdx - $delta; $currentIdx = $currentIdx + $delta; if ($currentIdx < 0) $currentIdx = 0; SetValue(NP_ID_CDDIRECTORYIDX, $currentIdx); }
function Entertainment_SetRemoteControl($Id, $Value) { $DeviceName = IPS_GetName(IPS_GetParent($Id)); if (!isDevicePoweredOnByDeviceName($DeviceName)) { return; } IPSLogger_Dbg(__file__, 'Set RemoteControl for Device "'.$DeviceName.'": '.$Value); SetValue($Id, $Value); Entertainment_SetRoomControlByDeviceControlId($Id, $Value); }
public function nodelist() { if ($this->isPost()) { $access = $_POST['access']; SetValue('accessmode', $access); cleanCache(); $this->success("修改成功!"); } $this->access = GetValue('accessmode') ? GetValue('accessmode') : 'module'; $this->display(); }
function Entertainment_SetRoomPower($PowerId, $Value, $PowerOnDevices=true) { if (GetValue($PowerId) <> $Value) { IPSLogger_Inf(__file__, 'Set Power for Room "'.IPS_GetName(IPS_GetParent($PowerId)).'" '.bool2OnOff($Value)); SetValue($PowerId, $Value); Entertainment_SetRoomVisible($PowerId, $Value); if ($PowerOnDevices) { Entertainment_SetDevicePowerByRoomId(IPS_GetParent($PowerId), $Value); } Entertainment_SyncRoomControls(IPS_GetParent($PowerId)); } }
public function RequestAction($Ident, $Value) { switch($Ident) { case "TestVariable": SetValue($this->GetIDForIdent($Ident), $Value); break; default: throw new Exception("Invalid ident"); } }
/** * @param Gdn_Controller $Sender * @param array $Args */ public function EntryController_Render_Before($Sender, $Args) { if ($Sender->RequestMethod != 'passwordreset') { return; } if (isset($Sender->Data['User'])) { // Get all of the users with the same email. $Email = $Sender->Data('User.Email'); $Users = Gdn::SQL()->Select('Name')->From('User')->Where('Email', $Email)->Get()->ResultArray(); $Names = array_column($Users, 'Name'); SetValue('Name', $Sender->Data['User'], implode(', ', $Names)); } }
protected function CreateAndUpdateVariable($variableType, $variableName, $value, $parent, $ident) { $existingVariableId = @IPS_GetObjectIDByIdent($ident, $parent); if (!$existingVariableId) { $newVariableId = IPS_CreateVariable($variableType); IPS_SetName($newVariableId, $variableName); SetValue($newVariableId, $value); IPS_SetParent($newVariableId, $parent); IPS_SetIdent($newVariableId, $ident); return $newVariableId; } else { SetValue($existingVariableId, $value); return $existingVariableId; } }
function Payment() { $model = D('Payment'); $this->list = $model->order('sort desc')->select(); if ($this->isPost()) { $id = implode(',', (array) $_POST['id']); $map['id'] = array('in', $id); $list = $model->where($map)->getField('id,name'); $status = $_POST['status']; foreach ($list as $val) { SetValue($val . '_status', $status); } $count = count($list); cleanCache(); $this->success(($status ? '启用了' : '禁用了') . $count . '个付款方式!'); } $this->display(); }
/** * Build the Message's Location property and add it. * * @param mixed $Message Array or object. * @return mixed Array or object given with Location property/key added. */ public function DefineLocation($Message) { $Controller = GetValue('Controller', $Message); $Application = GetValue('Application', $Message); $Method = GetValue('Method', $Message); if (in_array($Controller, $this->_SpecialLocations)) { SetValue('Location', $Message, $Controller); } else { SetValue('Location', $Message, $Application); if (!StringIsNullOrEmpty($Controller)) { SetValue('Location', $Message, GetValue('Location', $Message) . '/' . $Controller); } if (!StringIsNullOrEmpty($Method)) { SetValue('Location', $Message, GetValue('Location', $Message) . '/' . $Method); } } return $Message; }
/** * This function will be available automatically after the module is imported with the module control. * Using the custom prefix this function will be callable from PHP and JSON-RPC through: * * EZVO_RequestInfo($id); * */ public function RequestInfo() { $city = $this->ReadPropertyString("city"); $buffer = file_get_contents("http://www.zvo-entsorgung.de/service/abfall-abfuhrkalender-" . date("Y") . ".html?tx_aak_pi1%5B__referrer%5D%5BextensionName%5D=Aak&tx_aak_pi1%5B__referrer%5D%5BcontrollerName%5D=Form&tx_aak_pi1%5B__referrer%5D%5BactionName%5D=index&tx_aak_pi1%5B__hmac%5D=a%3A3%3A%7Bs%3A8%3A%22cityForm%22%3Ba%3A1%3A%7Bs%3A4%3A%22city%22%3Bi%3A1%3B%7Ds%3A6%3A%22action%22%3Bi%3A1%3Bs%3A10%3A%22controller%22%3Bi%3A1%3B%7D0e741c742f645570bede528d6702485f9bf59d6d&tx_aak_pi1%5BcityForm%5D%5Bcity%5D=" . urlencode($city)); $buffer = stristr($buffer, "Ihre nächsten Abfuhrtermine für:"); $buffer = stristr($buffer, "Gelber Sack, Biotonne, Restmülltonne:"); $buffer = stristr($buffer, "<td class=\"right\">"); $buffer = stristr($buffer, ">"); $date1 = substr($buffer, 1, strpos($buffer, "</td>") - 1); SetValue($this->GetIDForIdent("WasteTime"), strtotime($date1)); SetValue($this->GetIDForIdent("BioTime"), strtotime($date1)); SetValue($this->GetIDForIdent("RecycleTime"), strtotime($date1)); $buffer = stristr($buffer, "Blaue Tonne:"); $buffer = stristr($buffer, "<td class=\"right\">"); $buffer = stristr($buffer, ">"); $date2 = substr($buffer, 1, strpos($buffer, "</td>") - 1); SetValue($this->GetIDForIdent("PaperTime"), strtotime($date2)); }
public function SettingsController_PageSpeed_Create($Sender) { $Sender->Permission('Garden.Plugins.Manage'); if ('cleancache' == GetValue(0, $Sender->RequestArgs)) { self::CleanCache(); Redirect('settings/pagespeed'); } elseif ('disable' == GetValue(0, $Sender->RequestArgs)) { SaveToConfig('EnabledPlugins.PageSpeed', False); Redirect('/dashboard/settings/plugins'); } $Sender->AddSideMenu(); $Sender->Title('Page Speed'); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $Sender->Form->SetModel($ConfigurationModel); $ConfigurationModel->SetField(array('Plugins.PageSpeed.AllInOne', 'Plugins.PageSpeed.DeferJavaScript', 'Plugins.PageSpeed.ParallelizeEnabled', 'Plugins.PageSpeed.ParallelizeHosts', 'Plugins.PageSpeed.CDN.jquery', 'Plugins.PageSpeed.CDN.jqueryui', 'Plugins.PageSpeed.CDN.jqueryui-theme')); if ($Sender->Form->AuthenticatedPostBack()) { //$Validation->ApplyRule('Plugin.Example.RenderCondition', 'Required'); $FormValues = $Sender->Form->FormValues(); $Integer = array('Plugins.PageSpeed.AllInOne', 'Plugins.PageSpeed.DeferJavaScript'); foreach ($Integer as $Name) { settype($FormValues[$Name], 'int'); } settype($FormValues['Plugins.PageSpeed.ParallelizeEnabled'], 'bool'); $ParallelizeHosts = SplitUpString($FormValues['Plugins.PageSpeed.ParallelizeHosts'], ',', 'trim strtolower'); if (count($ParallelizeHosts) == 0) { SetValue('Plugins.PageSpeed.ParallelizeHosts', $FormValues, Null); SetValue('Plugins.PageSpeed.ParallelizeEnabled', $FormValues, False); } else { SetValue('Plugins.PageSpeed.ParallelizeHosts', $FormValues, implode(', ', $ParallelizeHosts)); } $Sender->Form->FormValues($FormValues); $Sender->Form->Save(); $Sender->InformMessage(T('Saved'), array('Sprite' => 'Check', 'CssClass' => 'Dismissable AutoDismiss')); } else { $Sender->Form->SetData($ConfigurationModel->Data); } $Sender->SetData('GroupingItems', array('Three groups (library, applications, plugins)', 'All css and javascript files combined into one file', 'Minify javascript only')); $Sender->SetData('DeferJavaScriptItems', array(0 => 'Disabled', 1 => htmlspecialchars('Just put <script> tags at bottom'), 2 => 'Dynamic loading (Dangerous! Something may not work)')); $Sender->View = dirname(__FILE__) . DS . 'views' . DS . 'settings.php'; $Sender->Render(); }
/** * This function will be available automatically after the module is imported with the module control. * Using the custom prefix this function will be callable from PHP and JSON-RPC through: * * GEO_ProcessHookData($id); * */ public function ProcessHookData() { //workaround for bug if (!isset($_IPS)) { global $_IPS; } if ($_IPS['SENDER'] == "Execute") { echo "This script cannot be used this way."; return; } if (!isset($_POST['device']) || !isset($_POST['id']) || !isset($_POST['name'])) { IPS_LogMessage("Geofency", "Malformed data: " . print_r($_POST, true)); return; } $deviceID = $this->CreateInstanceByIdent($this->InstanceID, $this->ReduceGUIDToIdent($_POST['device']), "Device"); SetValue($this->CreateVariableByIdent($deviceID, "Latitude", "Latitude", 2), floatval($_POST['latitude'])); SetValue($this->CreateVariableByIdent($deviceID, "Longitude", "Longitude", 2), floatval($_POST['longitude'])); SetValue($this->CreateVariableByIdent($deviceID, "Timestamp", "Timestamp", 1, "~UnixTimestamp"), intval(strtotime($_POST['date']))); SetValue($this->CreateVariableByIdent($deviceID, $this->ReduceGUIDToIdent($_POST['id']), utf8_decode($_POST['name']), 0, "~Presence"), intval($_POST['entry']) > 0); }
public function RequestRead() { $Address = 0x0 + ($this->ReadPropertyInteger("Phase") - 1) * 2; $Volt = $this->SendDataToParent(json_encode(array("DataID" => "{E310B701-4AE7-458E-B618-EC13A1A6F6A8}", "Function" => 3, "Address" => $Address, "Quantity" => 2, "Data" => ""))); if ($Volt === false) { return; } $Volt = unpack("n*", substr($Volt, 2)); $Address = 0xc + ($this->ReadPropertyInteger("Phase") - 1) * 2; $Ampere = $this->SendDataToParent(json_encode(array("DataID" => "{E310B701-4AE7-458E-B618-EC13A1A6F6A8}", "Function" => 3, "Address" => $Address, "Quantity" => 2, "Data" => ""))); if ($Ampere === false) { return; } $Ampere = unpack("n*", substr($Ampere, 2)); $Address = 0x12 + ($this->ReadPropertyInteger("Phase") - 1) * 2; $Watt = $this->SendDataToParent(json_encode(array("DataID" => "{E310B701-4AE7-458E-B618-EC13A1A6F6A8}", "Function" => 3, "Address" => $Address, "Quantity" => 2, "Data" => ""))); if ($Watt === false) { return; } $Watt = unpack("n*", substr($Watt, 2)); $Address = 0x46 + ($this->ReadPropertyInteger("Phase") - 1) * 2; $KWh = $this->SendDataToParent(json_encode(array("DataID" => "{E310B701-4AE7-458E-B618-EC13A1A6F6A8}", "Function" => 3, "Address" => $Address, "Quantity" => 2, "Data" => ""))); if ($KWh === false) { return; } $KWh = unpack("n*", substr($KWh, 2)); if (IPS_GetProperty(IPS_GetInstance($this->InstanceID)['ConnectionID'], "SwapWords")) { SetValue($this->GetIDForIdent("Volt"), ($Volt[1] + ($Volt[2] << 16)) / 10); SetValue($this->GetIDForIdent("Ampere"), ($Ampere[1] + ($Ampere[2] << 16)) / 1000); SetValue($this->GetIDForIdent("Watt"), ($Watt[1] + ($Watt[2] << 16)) / 10); SetValue($this->GetIDForIdent("kWh"), ($KWh[1] + ($KWh[2] << 16)) / 10); } else { SetValue($this->GetIDForIdent("Volt"), ($Volt[2] + ($Volt[1] << 16)) / 10); SetValue($this->GetIDForIdent("Ampere"), ($Ampere[2] + ($Ampere[1] << 16)) / 1000); SetValue($this->GetIDForIdent("Watt"), ($Watt[2] + ($Watt[1] << 16)) / 10); SetValue($this->GetIDForIdent("kWh"), ($KWh[2] + ($KWh[1] << 16)) / 10); } }
function MediaThumbnail($Media, $Data = FALSE) { $Media = (array) $Media; if (GetValue('ThumbPath', $Media)) { $Src = Gdn_Upload::Url(ltrim(GetValue('ThumbPath', $Media), '/')); } else { $Width = GetValue('ImageWidth', $Media); $Height = GetValue('ImageHeight', $Media); if (!$Width || !$Height) { $Height = MediaModel::ThumbnailHeight(); if (!$Height) { $Height = 100; } SetValue('ThumbHeight', $Media, $Height); return DefaultMediaThumbnail($Media); } $RequiresThumbnail = FALSE; if (MediaModel::ThumbnailHeight() && $Height > MediaModel::ThumbnailHeight()) { $RequiresThumbnail = TRUE; } elseif (MediaModel::ThumbnailWidth() && $Width > MediaModel::ThumbnailWidth()) { $RequiresThumbnail = TRUE; } $Path = ltrim(GetValue('Path', $Media), '/'); if ($RequiresThumbnail) { $Src = Url('/utility/thumbnail/' . GetValue('MediaID', $Media, 'x') . '/' . $Path, TRUE); } else { $Src = Gdn_Upload::Url($Path); } } if ($Data) { $Result = array('src' => $Src, 'width' => GetValue('ThumbWidth', $Media), 'height' => GetValue('ThumbHeight', $Media)); } else { $Result = Img($Src, array('class' => 'ImageThumbnail', 'width' => GetValue('ThumbWidth', $Media), 'height' => GetValue('ThumbHeight', $Media))); } return $Result; }
function index() { if ($this->isPost()) { SetValue('365webcall_name', rawurlencode($_POST['365webcall_name'])); SetValue('365webcall_email', $_POST['365webcall_email']); SetValue('365webcall_accountid', '0594trade'); SetValue('365webcall_status', $_POST['365webcall_status']); SetValue('365webcall_password', rawurlencode($_POST['365webcall_password'])); SetValue('365webcall_url', $_SERVER['HTTP_HOST']); cleanCache(); $this->success('操作成功!'); } else { $this->name = GetValue('365webcall_name'); $this->email = GetValue('365webcall_email'); $this->accountid = GetValue('365webcall_accountid'); $this->pwd = GetValue('365webcall_password'); $this->url = GetValue('365webcall_url'); $this->name2 = rawurldecode(GetValue('365webcall_name')); $this->email2 = GetValue('365webcall_email'); $this->accountid2 = GetValue('365webcall_accountid'); $this->pwd2 = rawurldecode(GetValue('365webcall_accountid')); $this->display(); } }
function Entertainment_SetDevicePowerByDeviceName($DeviceName, $Value, $MessageType=c_MessageType_Action) { IPSLogger_Trc(__file__, 'Handle Device Power for "'.$DeviceName.'" '.bool2OnOff($Value)); $PowerId = get_ControlIdByDeviceName($DeviceName, c_Control_DevicePower, false); if ($PowerId!==false) { if (!is_bool($Value)) { /*Toggle Power Value*/ $Value = !GetValue($PowerId); IPSLogger_Dbg(__file__, "Toogle Device Power for '$DeviceName' to ".bool2OnOff($Value)); } if (GetValue($PowerId) <> $Value) { IPSLogger_Inf(__file__, 'Set Device Power for "'.$DeviceName.'" '.bool2OnOff($Value)); if ($Value) { Entertainment_SendDataByDeviceName($DeviceName, c_Control_DevicePower, array(c_Property_CommPowerOn, c_Property_CommPower), $MessageType); } else { Entertainment_SendDataByDeviceName($DeviceName, c_Control_DevicePower, array(c_Property_CommPowerOff, c_Property_CommPower), $MessageType); } SetValue($PowerId, $Value); Entertainment_Connect($DeviceName, $Value, true); Entertainment_SetDeviceControlByDeviceName($DeviceName, c_Control_Muting, false); Entertainment_SetRoomPowerByDeviceName($DeviceName, $Value); } } }
/** * Join message counts into the discussion list. * @param DiscussionModel $Sender * @param array $Args */ public function DiscussionModel_AfterAddColumns_Handler($Sender, $Args) { if (!Gdn::Session()->UserID) { return; } $Data = $Args['Data']; $Result =& $Data->Result(); // Gather the discussion IDs. $DiscusisonIDs = array(); foreach ($Result as $Row) { $DiscusisonIDs[] = GetValue('DiscussionID', $Row); } // Grab all of the whispers associated to the discussions being looked at. $Sql = Gdn::SQL()->Select('c.DiscussionID')->Select('c.CountMessages', 'sum', 'CountMessages')->Select('c.DateUpdated', 'max', 'DateLastMessage')->From('Conversation c')->WhereIn('c.DiscussionID', $DiscusisonIDs)->GroupBy('c.DiscussionID'); if (!Gdn::Session()->CheckPermission('Conversations.Moderation.Manage')) { $Sql->Join('UserConversation uc', 'c.ConversationID = uc.ConversationID')->Where('uc.UserID', Gdn::Session()->UserID); } $Conversations = $Sql->Get()->ResultArray(); $Conversations = Gdn_DataSet::Index($Conversations, 'DiscussionID'); foreach ($Result as &$Row) { $DiscusisonID = GetValue('DiscussionID', $Row); $CRow = GetValue($DiscusisonID, $Conversations); if (!$CRow) { continue; } $DateLastViewed = GetValue('DateLastViewed', $Row); $DateLastMessage = $CRow['DateLastMessage']; $NewWhispers = Gdn_Format::ToTimestamp($DateLastViewed) < Gdn_Format::ToTimestamp($DateLastMessage); SetValue('CountWhispers', $Row, $CRow['CountMessages']); SetValue('DateLastWhisper', $Row, $DateLastMessage); SetValue('NewWhispers', $Row, $NewWhispers); } }
function writeReactions($Row) { $Attributes = GetValue('Attributes', $Row); if (is_string($Attributes)) { $Attributes = @unserialize($Attributes); SetValue('Attributes', $Row, $Attributes); } Gdn::controller()->EventArguments['ReactionTypes'] = array(); if ($ID = GetValue('CommentID', $Row)) { $RecordType = 'comment'; } elseif ($ID = GetValue('ActivityID', $Row)) { $RecordType = 'activity'; } else { $RecordType = 'discussion'; $ID = GetValue('DiscussionID', $Row); } Gdn::controller()->EventArguments['RecordType'] = $RecordType; Gdn::controller()->EventArguments['RecordID'] = $ID; echo '<div class="Reactions">'; Gdn_Theme::bulletRow(); // Write the flags. static $Flags = null; if ($Flags === null) { Gdn::controller()->EventArguments['Flags'] =& $Flags; Gdn::controller()->fireEvent('Flags'); } // Allow addons to work with flags Gdn::controller()->EventArguments['Flags'] =& $Flags; Gdn::controller()->fireEvent('BeforeFlag'); if (!empty($Flags) && is_array($Flags)) { echo Gdn_Theme::bulletItem('Flags'); echo ' <span class="FlagMenu ToggleFlyout">'; // Write the handle. echo anchor(sprite('ReactFlag', 'ReactSprite') . ' ' . wrap(t('Flag'), 'span', array('class' => 'ReactLabel')), '', 'Hijack ReactButton-Flag FlyoutButton', array('title' => t('Flag')), true); echo sprite('SpFlyoutHandle', 'Arrow'); echo '<ul class="Flyout MenuItems Flags" style="display: none;">'; foreach ($Flags as $Flag) { if (is_callable($Flag)) { echo '<li>' . call_user_func($Flag, $Row, $RecordType, $ID) . '</li>'; } else { echo '<li>' . reactionButton($Row, $Flag['UrlCode']) . '</li>'; } } Gdn::controller()->fireEvent('AfterFlagOptions'); echo '</ul>'; echo '</span> '; } Gdn::controller()->fireEvent('AfterFlag'); Gdn::controller()->fireEvent('AfterReactions'); echo '</div>'; Gdn::controller()->fireEvent('Replies'); }
$ldapUserAttributes = $cfgEngine->getValue("Users:ldap", "Attributes"); $ldapUserAttributesEx = $cfgTpl->getValue("Users:ldap", "Attributes"); SetValue("LdapUserBaseDn", $ldapUserBaseDn); SetValue("LdapUserBaseDnEx", $ldapUserBaseDnEx); SetValue("LdapUserSearchFilter", $ldapUserSearchFilter); SetValue("LdapUserSearchFilterEx", $ldapUserSearchFilterEx); SetValue("LdapUserAttributes", $ldapUserAttributes); SetValue("LdapUserAttributesEx", $ldapUserAttributesEx); // LDAP group provider information. $ldapGroupBaseDn = $cfgEngine->getValue("Groups:ldap", "BaseDN"); $ldapGroupBaseDnEx = $cfgTpl->getValue("Groups:ldap", "BaseDN"); $ldapGroupSearchFilter = $cfgEngine->getValue("Groups:ldap", "SearchFilter"); $ldapGroupSearchFilterEx = $cfgTpl->getValue("Groups:ldap", "SearchFilter"); $ldapGroupAttributes = $cfgEngine->getValue("Groups:ldap", "Attributes"); $ldapGroupAttributesEx = $cfgTpl->getValue("Groups:ldap", "Attributes"); $ldapGroupsToUserAttribute = $cfgEngine->getValue("Groups:ldap", "GroupsToUserAttribute"); $ldapGroupsToUserAttributeEx = $cfgTpl->getValue("Groups:ldap", "GroupsToUserAttribute"); $ldapGroupsToUserAttributeValue = $cfgEngine->getValue("Groups:ldap", "GroupsToUserAttributeValue"); $ldapGroupsToUserAttributeValueEx = $cfgTpl->getValue("Groups:ldap", "GroupsToUserAttributeValue"); SetValue("LdapGroupBaseDn", $ldapGroupBaseDn); SetValue("LdapGroupBaseDnEx", $ldapGroupBaseDnEx); SetValue("LdapGroupSearchFilter", $ldapGroupSearchFilter); SetValue("LdapGroupSearchFilterEx", $ldapGroupSearchFilterEx); SetValue("LdapGroupAttributes", $ldapGroupAttributes); SetValue("LdapGroupAttributesEx", $ldapGroupAttributesEx); SetValue("LdapGroupsToUserAttribute", $ldapGroupsToUserAttribute); SetValue("LdapGroupsToUserAttributeEx", $ldapGroupsToUserAttributeEx); SetValue("LdapGroupsToUserAttributeValue", $ldapGroupsToUserAttributeValue); SetValue("LdapGroupsToUserAttributeValueEx", $ldapGroupsToUserAttributeValueEx); // Process template. ProcessTemplate("settings/backend.html.php");
/** * Modifies category data before it is returned. * * Adds CountAllDiscussions column to each category representing the sum of * discussions within this category as well as all subcategories. * * @since 2.0.17 * @access public * * @param object $Data SQL result. */ public static function AddCategoryColumns($Data) { $Result =& $Data->Result(); $Result2 = $Result; foreach ($Result as &$Category) { if (!property_exists($Category, 'CountAllDiscussions')) { $Category->CountAllDiscussions = $Category->CountDiscussions; } if (!property_exists($Category, 'CountAllComments')) { $Category->CountAllComments = $Category->CountComments; } // Calculate the following field. $Following = !((bool) GetValue('Archived', $Category) || (bool) GetValue('Unfollow', $Category)); $Category->Following = $Following; $DateMarkedRead = GetValue('DateMarkedRead', $Category); $UserDateMarkedRead = GetValue('UserDateMarkedRead', $Category); if (!$DateMarkedRead) { $DateMarkedRead = $UserDateMarkedRead; } elseif ($UserDateMarkedRead && Gdn_Format::ToTimestamp($UserDateMarkedRead) > Gdn_Format::ToTimeStamp($DateMarkedRead)) { $DateMarkedRead = $UserDateMarkedRead; } // Set appropriate Last* columns. SetValue('LastTitle', $Category, GetValue('LastDiscussionTitle', $Category, NULL)); $LastDateInserted = GetValue('LastDateInserted', $Category, NULL); if (GetValue('LastCommentUserID', $Category) == NULL) { SetValue('LastCommentUserID', $Category, GetValue('LastDiscussionUserID', $Category, NULL)); SetValue('DateLastComment', $Category, GetValue('DateLastDiscussion', $Category, NULL)); SetValue('LastUserID', $Category, GetValue('LastDiscussionUserID', $Category, NULL)); $LastDiscussion = ArrayTranslate($Category, array('LastDiscussionID' => 'DiscussionID', 'CategoryID' => 'CategoryID', 'LastTitle' => 'Name')); SetValue('LastUrl', $Category, DiscussionUrl($LastDiscussion, FALSE, '//') . '#latest'); if (is_null($LastDateInserted)) { SetValue('LastDateInserted', $Category, GetValue('DateLastDiscussion', $Category, NULL)); } } else { $LastDiscussion = ArrayTranslate($Category, array('LastDiscussionID' => 'DiscussionID', 'CategoryID' => 'CategoryID', 'LastTitle' => 'Name')); SetValue('LastUserID', $Category, GetValue('LastCommentUserID', $Category, NULL)); SetValue('LastUrl', $Category, DiscussionUrl($LastDiscussion, FALSE, '//') . '#latest'); if (is_null($LastDateInserted)) { SetValue('LastDateInserted', $Category, GetValue('DateLastComment', $Category, NULL)); } } $LastDateInserted = GetValue('LastDateInserted', $Category, NULL); if ($DateMarkedRead) { if ($LastDateInserted) { $Category->Read = Gdn_Format::ToTimestamp($DateMarkedRead) >= Gdn_Format::ToTimestamp($LastDateInserted); } else { $Category->Read = TRUE; } } else { $Category->Read = FALSE; } foreach ($Result2 as $Category2) { if ($Category2->TreeLeft > $Category->TreeLeft && $Category2->TreeRight < $Category->TreeRight) { $Category->CountAllDiscussions += $Category2->CountDiscussions; $Category->CountAllComments += $Category2->CountComments; } } } }
protected function _DiscussionOptions($Sender, $DiscussionID) { $Sender->Form = new Gdn_Form(); $Discussion = $Sender->DiscussionModel->GetID($DiscussionID); if (!$Discussion) { throw NotFoundException('Discussion'); } // Both '' and 'Discussion' denote a discussion type of discussion. if (!GetValue('Type', $Discussion)) { SetValue('Type', $Discussion, 'Discussion'); } if ($Sender->Form->IsPostBack()) { $Sender->DiscussionModel->SetField($DiscussionID, 'Type', $Sender->Form->GetFormValue('Type')); // $Form = new Gdn_Form(); $Sender->Form->SetValidationResults($Sender->DiscussionModel->ValidationResults()); // if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL || $Redirect) // $Sender->RedirectUrl = Gdn::Controller()->Request->PathAndQuery(); Gdn::Controller()->JsonTarget('', '', 'Refresh'); } else { $Sender->Form->SetData($Discussion); } $Sender->SetData('Discussion', $Discussion); $Sender->SetData('_Types', array('Question' => '@' . T('Question Type', 'Question'), 'Discussion' => '@' . T('Discussion Type', 'Discussion'))); $Sender->SetData('Title', T('Q&A Options')); $Sender->Render('DiscussionOptions', '', 'plugins/QnA'); }
public static function SortAddons(&$Array) { // Make sure every addon has a name. foreach ($Array as $Key => $Value) { $Name = GetValue('Name', $Value, $Key); SetValue('Name', $Array[$Key], $Name); } uasort($Array, array('SettingsController', 'CompareAddonName')); }
function NetPlayer_RefreshTrackListValue() { $currentIdx = -1; $player = NetPlayer_GetIPSComponentPlayer(); $currentName = $player->GetTrackName(); $currentName = NetPlayer_GetTrackName($currentName); $currentName = str_replace(GetValue(NP_ID_CDINTERPRET).' - ', '', $currentName); $profileData = IPS_GetVariableProfile('NetPlayer_CDTrackList'); $associations = $profileData['Associations']; foreach ($associations as $idx=>$data) { IPSLogger_Trc(__file__, "Idx=$idx, '$currentName' --> '".$data['Name']."'"); if ($currentName == $data['Name']) { $currentIdx = $data['Value']; } } if (GetValue(NP_ID_CDTRACKLIST)<>$currentIdx ) { SetValue(NP_ID_CDTRACKLIST, $currentIdx); } }