/** * put your comment there... * */ protected function pinsMap() { // Initialize. $map = array(); $mdlBlocks = new CJTBlocksModel(); $blockId = $this->getBlockId(); // Query block pinPoint field. $assignedPinPoints = $mdlBlocks->getBlock($blockId, array(), array('id', 'pinPoint'), false)->pinPoint; // Return map. return $this->auxHelper->getPinsArray($assignedPinPoints); }
/** * put your comment there... * * @param mixed $blockData */ public static function arrangePins(&$blockData) { $pinsGroupNames = array_flip(array_merge(array_keys(self::getCustomPins()), array('pinPoint'))); $dbDriver = cssJSToolbox::getInstance()->getDBDriver(); $mdlBlock = new CJTBlocksModel(); $block = $mdlBlock->getBlock($blockData->id, array(), array('id', 'pinPoint')); $submittedPins = array_intersect_key((array) $blockData, $pinsGroupNames); $assignedPins = array_intersect_key((array) $block, $pinsGroupNames); // Transfer assigned PinPoint from "FLAGGED INTEGER" TO "ARRAY" like // the other pins. $assignedPins['pinPoint'] = array_keys(CJT_Models_Block_Assignmentpanel_Helpers_Auxiliary::getInstance()->getPinsArray($assignedPins['pinPoint'])); // Walk through all assigned pins. // Unassigned any item with 'value=false'. // Whenever an item is found on the submitted // pins it should be removed from the submitted list foreach ($submittedPins as $groupName => $submittedGroup) { // Get assigned pins group if found if (!isset($assignedPins[$groupName])) { // Initialize new assigned group array. $assignedPins[$groupName] = array(); } $assignedGroup =& $assignedPins[$groupName]; // For every submitted item there is three types. // 1. Already assigned :WHEN: (sync == true and value == true) // 2. Unassigned :WHEN: (value == false) // 3. Newly assigned :WHEN: (sync = false). foreach ($submittedGroup as $submittedPinId => $submittedPin) { // Unassigned pin if (!$submittedPin['value']) { // Find the submittedPinId AssignedPins index. $assignedIndex = array_search($submittedPinId, $assignedGroup); // Unassigned it :REMOVE FROM ARRAY: unset($assignedGroup[$assignedIndex]); } else { if (!$submittedPin['sync']) { // Add newly assigned item. $assignedGroup[] = $submittedPinId; } } } } // Copy all assigned pins back to the block object. foreach ($assignedPins as $groupName => $finalGroupAssigns) { $blockData->{$groupName} = $finalGroupAssigns; } // Important for caller short-circle condition. return true; }
/** * put your comment there... * */ protected function restoreRevisionAction() { // Initialize. $mdlBlocks = new CJTBlocksModel(); $tblCodeFile = new CJTBlockFilesTable(cssJSToolbox::getInstance()->getDBDriver()); // Get revision ID. $rId = (int) $_GET['rid']; $bId = (int) $_GET['bid']; // Get Revision Block + Revision Code. $revisionBlock = $mdlBlocks->getBlock($rId, array(), array('id', 'pinPoint', 'links', 'expressions', 'masterFile')); $revisionBlock->code = $tblCodeFile->set('blockId', $rId)->set('id', $revisionBlock->masterFile)->load()->getData()->code; // If code === null set it to empoty string '' as null woulod // prevent the field from being in the query, cause SQL error. if ($revisionBlock->code === null) { $revisionBlock->code = ''; } // Code File Fields. $revisionBlock->activeFileId = $revisionBlock->masterFile; $revisionBlock->masterFile = null; // This is just for querying CodeFile. DONT UPDATE. // Restore Block. $revisionBlock->id = $bId; $mdlBlocks->update($revisionBlock, true); $mdlBlocks->save(); // Return TRUE. $this->response = true; }