Beispiel #1
0
					$doProcessArrangement = true;
					if (PERMISSIONS_MODEL == 'advanced') {
						// first, we check to see if we have permissions to edit the area contents for the source area.
						$arHandle = Area::getAreaHandleFromID($_POST['sourceBlockAreaID']);
						$ar = Area::getOrCreate($nvc, $arHandle);
						$ap = new Permissions($ar);
						if (!$ap->canEditAreaContents()) {
							$r = new stdClass;
							$r->error = true;
							$doProcessArrangement = false;
							$r->message = t('You may not arrange the contents of area %s.', $arHandle);
						} else {
							// now we get further in. We check to see if we're dealing with both a source AND a destination area.
							// if so, we check the area permissions for the destination area.
							if ($_POST['sourceBlockAreaID'] != $_POST['destinationBlockAreaID']) {
								$destAreaHandle = Area::getAreaHandleFromID($_POST['destinationBlockAreaID']);
								$destArea = Area::getOrCreate($nvc, $destAreaHandle);
								$destAP = new Permissions($destArea);
								if (!$destAP->canEditAreaContents()) {
									$r = new stdClass;
									$r->error = true;
									$doProcessArrangement = false;
									$r->message = t('You may not arrange the contents of area %s.', $destAreaHandle);
								} else {
									// we're not done yet. Now we have to check to see whether this user has permission to add
									// a block of this type to the destination area.
									$b = Block::getByID($_REQUEST['sourceBlockID'], $nvc, $arHandle);
									$bt = $b->getBlockTypeObject();
									if (!$destAP->canAddBlock($bt)) {
										$doProcessArrangement = false;
										$r = new stdClass;
Beispiel #2
0
 /** 
  * Takes an array of area/block values and makes that the arrangement for this page's version
  * Format is like: $area[10][0] = 2, $area[10][1] = 8, $area[15][0] = 27, with the area ID being the 
  * key and the block IDs being 1-n values inside it
  * @param array $areas
  * @param array $affectedAreaIDs
  *		IDs of the areas affected by the process arrangement (source and destination when moving blocks between areas, only source if moving in the same area).
  *		If specified, we'll sort out only the blocks in the specified areas.
  *		If not specified, $areas must contain all the blocks from all the areas of the current collection.
  */
 public function processArrangement($areas, $affectedAreaIDs = array())
 {
     // this function is called via ajax, so it's a bit wonky, but the format is generally
     // a{areaID} = array(b1, b2, b3) (where b1, etc... are blocks with ids appended.)
     $db = Loader::db();
     $s = 'delete from CollectionVersionBlockStyles where cID = ? and cvID = ?';
     $q = array($this->getCollectionID(), $this->getVersionID());
     $onlySpecificAreas = false;
     if (!empty($affectedAreaIDs)) {
         foreach ($affectedAreaIDs as $arID) {
             if (!$onlySpecificAreas) {
                 $onlySpecificAreas = true;
                 $s .= ' and (';
             } else {
                 $s .= ' or ';
             }
             $s .= 'arHandle = ?';
             $q[] = Area::getAreaHandleFromID($arID);
         }
     }
     if ($onlySpecificAreas) {
         $s .= ')';
     }
     $db->Execute($s, $q);
     foreach ($areas as $arID => $blocks) {
         if (intval($arID) > 0) {
             // this is a serialized area;
             $arHandle = Area::getAreaHandleFromID($arID);
             $startDO = 0;
             foreach ($blocks as $bIdentifier) {
                 $bID = 0;
                 $csrID = 0;
                 $bd2 = explode('-', $bIdentifier);
                 $bID = $bd2[0];
                 $csrID = $bd2[1];
                 if (intval($bID) > 0) {
                     $v = array($startDO, $arHandle, $bID, $this->getCollectionID(), $this->getVersionID());
                     try {
                         $db->query("update CollectionVersionBlocks set cbDisplayOrder = ?, arHandle = ? where bID = ? and cID = ? and (cvID = ? or cbIncludeAll = 1)", $v);
                         if ($csrID > 0) {
                             $db->query("insert into CollectionVersionBlockStyles (csrID, arHandle, bID, cID, cvID) values (?, ?, ?, ?, ?)", array($csrID, $arHandle, $bID, $this->getCollectionID(), $this->getVersionID()));
                         }
                         // update the style for any of these blocks
                     } catch (Exception $e) {
                     }
                     $startDO++;
                 }
             }
         }
     }
 }
Beispiel #3
0
 }
 if (PERMISSIONS_MODEL == 'advanced') {
     // first, we check to see if we have permissions to edit the area contents for the source area.
     $arHandle = Area::getAreaHandleFromID($sourceAreaID);
     $ar = Area::getOrCreate($nvc, $arHandle);
     $ap = new Permissions($ar);
     if (!$ap->canEditAreaContents()) {
         $r = new stdClass();
         $r->error = true;
         $doProcessArrangement = false;
         $r->message = t('You may not arrange the contents of area %s.', $arHandle);
     } else {
         // now we get further in. We check to see if we're dealing with both a source AND a destination area.
         // if so, we check the area permissions for the destination area.
         if ($sourceAreaID != $destinationAreaID) {
             $destAreaHandle = Area::getAreaHandleFromID($destinationAreaID);
             $destArea = Area::getOrCreate($nvc, $destAreaHandle);
             $destAP = new Permissions($destArea);
             if (!$destAP->canEditAreaContents()) {
                 $r = new stdClass();
                 $r->error = true;
                 $doProcessArrangement = false;
                 $r->message = t('You may not arrange the contents of area %s.', $destAreaHandle);
             } else {
                 // we're not done yet. Now we have to check to see whether this user has permission to add
                 // a block of this type to the destination area.
                 $b = Block::getByID($_REQUEST['sourceBlockID'], $nvc, $arHandle);
                 $bt = $b->getBlockTypeObject();
                 if (!$destAP->canAddBlock($bt)) {
                     $doProcessArrangement = false;
                     $r = new stdClass();