/** * Gets the module validations Info for the given editions and user * * @param CMS_user $user The user we want the validations for * @param integer $editions The editions we want the validations of * @param boolean $returnCount only return the count of validations * @return array(CMS_resourceValidation) The resourceValidations objects, false if noen found * @access public */ function getValidationsInfoByEditions(&$user, $editions, $returnCount = false) { $language = $user->getLanguage(); $validations = array(); $validationsCount = 0; if (is_array($this->_resourceInfo) && $this->_resourceInfo) { $primaryResource = $this->getPrimaryResourceInfo(); if ($editions & RESOURCE_EDITION_CONTENT) { //content and/or base data change $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\t" . $primaryResource['key'] . " as id\n\t\t\t\t\tfrom\n\t\t\t\t\t\t" . $primaryResource['tableName'] . "_edited,\n\t\t\t\t\t\tresources,\n\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\twhere\n\t\t\t\t\t\t" . $primaryResource['resource'] . " = id_res\n\t\t\t\t\t\tand status_res = id_rs\n\t\t\t\t\t\tand location_rs = '" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\t\t\tand proposedFor_rs = 0\n\t\t\t\t\t\tand (editions_rs & " . RESOURCE_EDITION_CONTENT . "\n\t\t\t\t\t\t\t\tand not (validationsRefused_rs & " . RESOURCE_EDITION_CONTENT . "))\n\t\t\t\t"; $q = new CMS_query($sql); if ($returnCount) { $validationsCount += $q->getNumRows(); } else { while ($id = $q->getValue("id")) { $validation = new CMS_resourceValidationInfo($this->_codename, RESOURCE_EDITION_CONTENT, $id); if (!$validation->hasError()) { $validation->setValidationTypeLabel($language->getMessage($this->getModuleValidationLabel("edition"), false, $this->_codename)); $validations[] = $validation; } } } } if ($editions & RESOURCE_EDITION_LOCATION) { //Location change $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\t" . $primaryResource['key'] . " as id\n\t\t\t\t\tfrom\n\t\t\t\t\t\t" . $primaryResource['tableName'] . "_edited,\n\t\t\t\t\t\tresources,\n\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\twhere\n\t\t\t\t\t\t" . $primaryResource['resource'] . " = id_res\n\t\t\t\t\t\tand status_res = id_rs\n\t\t\t\t\t\tand location_rs = '" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\t\t\tand proposedFor_rs != 0\n\t\t\t\t\t\tand not (validationsRefused_rs & " . RESOURCE_EDITION_LOCATION . ")\n\t\t\t\t"; $q = new CMS_query($sql); if ($returnCount) { $validationsCount += $q->getNumRows(); } else { while ($id = $q->getValue("id")) { $validation = new CMS_resourceValidationInfo($this->_codename, RESOURCE_EDITION_LOCATION, $id); if (!$validation->hasError()) { $validation->setValidationTypeLabel($language->getMessage($this->getModuleValidationLabel("locationChange"), false, $this->_codename)); $validations[] = $validation; } } } } } return $returnCount ? $validationsCount : $validations; }
/** * Gets the module validations Info for the given editions and user * * @param CMS_user $user The user we want the validations for * @param integer $editions The editions we want the validations of * @param boolean $returnCount only return the count of validations * @return array(CMS_resourceValidation) The resourceValidations objects, false if noen found * @access public */ function getValidationsInfoByEditions(&$user, $editions, $returnCount = false) { $language = $user->getLanguage(); $validations = array(); $validationsCount = 0; if (CMS_poly_object_catalog::hasPrimaryResource($this->getCodename())) { //get object type ID $objectID = CMS_poly_object_catalog::getPrimaryResourceObjectType($this->getCodename()); //get viewvable objects list for current user if (CMS_poly_object_catalog::objectHasCategories($objectID)) { $objects = CMS_poly_object_catalog::getAllObjects($objectID, false, array(), false); //$where = (is_array($objects) && $objects) ? ' and objectID in ('.implode(',',$objects).')' : ''; if (is_array($objects) && $objects) { $where = ' and objectID in (' . implode(',', $objects) . ')'; } else { return $validations; } } else { $where = ''; } $this->getPrimaryResourceDefinition(); if ($editions & RESOURCE_EDITION_CONTENT) { //content and/or base data change $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\tobjectID as id\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_integer_edited,\n\t\t\t\t\t\tmod_object_polyobjects,\n\t\t\t\t\t\tresources,\n\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\twhere\n\t\t\t\t\t\tvalue = id_res\n\t\t\t\t\t\tand object_type_id_moo = '" . $objectID . "'\n\t\t\t\t\t\tand id_moo = objectID\n\t\t\t\t\t\tand objectFieldID = 0\n\t\t\t\t\t\tand objectSubFieldID = 0\n\t\t\t\t\t\tand status_res = id_rs\n\t\t\t\t\t\tand location_rs = '" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\t\t\tand proposedFor_rs = 0\n\t\t\t\t\t\tand (editions_rs & " . RESOURCE_EDITION_CONTENT . "\n\t\t\t\t\t\t\t\tand not (validationsRefused_rs & " . RESOURCE_EDITION_CONTENT . "))\n\t\t\t\t\t\t{$where}\n\t\t\t\t"; $q = new CMS_query($sql); if ($returnCount) { $validationsCount += $q->getNumRows(); } else { while ($id = $q->getValue("id")) { $validation = new CMS_resourceValidationInfo($this->_codename, RESOURCE_EDITION_CONTENT, $id); if (!$validation->hasError()) { $validation->setValidationTypeLabel($language->getMessage(self::MESSAGE_MOD_POLYMOD_VALIDATION_EDITION, array($this->_primaryResourceObjectDefinition->getLabel($language)), MOD_POLYMOD_CODENAME)); $validations[] = $validation; } } } } if ($editions & RESOURCE_EDITION_LOCATION) { //Location change $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\tobjectID as id\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_subobject_integer_edited,\n\t\t\t\t\t\tmod_object_polyobjects,\n\t\t\t\t\t\tresources,\n\t\t\t\t\t\tresourceStatuses\n\t\t\t\t\twhere\n\t\t\t\t\t\tvalue = id_res\n\t\t\t\t\t\tand object_type_id_moo = '" . $objectID . "'\n\t\t\t\t\t\tand id_moo = objectID\n\t\t\t\t\t\tand objectFieldID = 0\n\t\t\t\t\t\tand objectSubFieldID = 0\n\t\t\t\t\t\tand status_res = id_rs\n\t\t\t\t\t\tand location_rs = '" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\t\t\tand proposedFor_rs != 0\n\t\t\t\t\t\tand not (validationsRefused_rs & " . RESOURCE_EDITION_LOCATION . ")\n\t\t\t\t\t\t{$where}\n\t\t\t\t"; $q = new CMS_query($sql); if ($returnCount) { $validationsCount += $q->getNumRows(); } else { while ($id = $q->getValue("id")) { $validation = new CMS_resourceValidationInfo($this->_codename, RESOURCE_EDITION_LOCATION, $id); if (!$validation->hasError()) { $validation->setValidationTypeLabel($language->getMessage(self::MESSAGE_MOD_POLYMOD_VALIDATION_LOCATIONCHANGE, array($this->_primaryResourceObjectDefinition->getLabel($language)), MOD_POLYMOD_CODENAME)); $validations[] = $validation; } } } } } return $returnCount ? $validationsCount : $validations; }
/** * Gets the module validations Info for the given editions and user * * @param CMS_user $user The user we want the validations for * @param integer $editions The editions we want the validations of * @return array(CMS_resourceValidation) The resourceValidations objects, false if noen found * @access public */ function getValidationsInfoByEditions(&$user, $editions) { $language = $user->getLanguage(); $validations = array(); if ($editions & RESOURCE_EDITION_LOCATION) { //Location change $sql = "\n\t\t\t\tselect\n\t\t\t\t\tid_pag\n\t\t\t\tfrom\n\t\t\t\t\tpages,\n\t\t\t\t\tresources,\n\t\t\t\t\tresourceStatuses\n\t\t\t\twhere\n\t\t\t\t\tresource_pag = id_res\n\t\t\t\t\tand status_res = id_rs\n\t\t\t\t\tand location_rs = '" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\t\tand proposedFor_rs != 0\n\t\t\t\t\tand not (validationsRefused_rs & " . RESOURCE_EDITION_LOCATION . ")\n\t\t\t"; $q = new CMS_query($sql); while ($id = $q->getValue("id_pag")) { //check if the page is editable by the user. If not, can't validate it if (!$user->hasPageClearance($id, CLEARANCE_PAGE_EDIT)) { continue; } //$page = $this->getResourceByID($id); $validation = new CMS_resourceValidationInfo($this->_codename, RESOURCE_EDITION_LOCATION, $id); if (!$validation->hasError()) { $validation->setValidationTypeLabel($language->getMessage(self::MESSAGE_MOD_STANDARD_VALIDATION_LOCATIONCHANGE)); $validations[] = $validation; } } } if ($editions & RESOURCE_EDITION_CONTENT || $editions & RESOURCE_EDITION_BASEDATA) { //content and/or base data change $sql = "\n\t\t\t\tselect\n\t\t\t\t\tid_pag,\n\t\t\t\t\teditions_rs,\n\t\t\t\t\tpublication_rs\n\t\t\t\tfrom\n\t\t\t\t\tpages,\n\t\t\t\t\tresources,\n\t\t\t\t\tresourceStatuses\n\t\t\t\twhere\n\t\t\t\t\tresource_pag = id_res\n\t\t\t\t\tand status_res = id_rs\n\t\t\t\t\tand location_rs = '" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\t\tand proposedFor_rs = 0\n\t\t\t\t\tand ((editions_rs & " . RESOURCE_EDITION_CONTENT . "\n\t\t\t\t\t\t\tand not (validationsRefused_rs & " . RESOURCE_EDITION_CONTENT . "))\n\t\t\t\t\t\tor (editions_rs & " . RESOURCE_EDITION_BASEDATA . "\n\t\t\t\t\t\t\tand not (validationsRefused_rs & " . RESOURCE_EDITION_BASEDATA . ")))\n\t\t\t"; $q = new CMS_query($sql); while ($data = $q->getArray()) { $id = $data["id_pag"]; //check if the page is editable by the user. If not, can't validate it if (!$user->hasPageClearance($id, CLEARANCE_PAGE_EDIT)) { continue; } //check if the page is not in draft only state. If it is, can't validate it if ($data['publication_rs'] == RESOURCE_PUBLICATION_NEVERVALIDATED) { $page = $this->getResourceByID($id); if ($page->isDraft()) { continue; } } $editions = RESOURCE_EDITION_CONTENT + RESOURCE_EDITION_BASEDATA; $validation = new CMS_resourceValidationInfo($this->_codename, $editions, $id); if (!$validation->hasError()) { $validation->setValidationTypeLabel($language->getMessage(self::MESSAGE_MOD_STANDARD_VALIDATION_EDITION)); $validations[] = $validation; } } } if ($editions & RESOURCE_EDITION_SIBLINGSORDER) { //siblings order change $sql = "\n\t\t\t\tselect\n\t\t\t\t\tid_pag\n\t\t\t\tfrom\n\t\t\t\t\tpages,\n\t\t\t\t\tresources,\n\t\t\t\t\tresourceStatuses\n\t\t\t\twhere\n\t\t\t\t\tresource_pag = id_res\n\t\t\t\t\tand status_res = id_rs\n\t\t\t\t\tand location_rs = '" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\t\tand proposedFor_rs = 0\n\t\t\t\t\tand editions_rs & " . RESOURCE_EDITION_SIBLINGSORDER . "\n\t\t\t\t\tand not (validationsRefused_rs & " . RESOURCE_EDITION_SIBLINGSORDER . ")\n\t\t\t"; $q = new CMS_query($sql); while ($data = $q->getArray()) { $id = $data["id_pag"]; //check if the page is editable by the user. If not, can't validate it if (!$user->hasPageClearance($id, CLEARANCE_PAGE_EDIT)) { continue; } $editions = RESOURCE_EDITION_SIBLINGSORDER; //$page = $this->getResourceByID($id); $validation = new CMS_resourceValidationInfo($this->_codename, $editions, $id); if (!$validation->hasError()) { $validation->setValidationTypeLabel($language->getMessage(self::MESSAGE_MOD_STANDARD_VALIDATION_SIBLINGSORDER)); $validations[] = $validation; } } } if ($editions & RESOURCE_EDITION_MOVE) { //siblings order change $sql = "\n\t\t\t\tselect\n\t\t\t\t\tid_pag\n\t\t\t\tfrom\n\t\t\t\t\tpages,\n\t\t\t\t\tresources,\n\t\t\t\t\tresourceStatuses\n\t\t\t\twhere\n\t\t\t\t\tresource_pag = id_res\n\t\t\t\t\tand status_res = id_rs\n\t\t\t\t\tand location_rs = '" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\t\tand proposedFor_rs = 0\n\t\t\t\t\tand editions_rs & " . RESOURCE_EDITION_MOVE . "\n\t\t\t\t\tand not (validationsRefused_rs & " . RESOURCE_EDITION_MOVE . ")\n\t\t\t"; $q = new CMS_query($sql); while ($data = $q->getArray()) { $id = $data["id_pag"]; //check if the page is editable by the user. If not, can't validate it if (!$user->hasPageClearance($id, CLEARANCE_PAGE_EDIT)) { continue; } $editions = RESOURCE_EDITION_MOVE; $validation = new CMS_resourceValidationInfo($this->_codename, $editions, $id); if (!$validation->hasError()) { $validation->setValidationTypeLabel($language->getMessage(self::MESSAGE_MOD_STANDARD_VALIDATION_MOVE)); $validations[] = $validation; } } } return $validations; }