/** * Check completion status * * @return object */ public function getStatus($manifest, $pub = NULL) { $status = new \Components\Publications\Models\Status(); // Get requirements to check against $field = $manifest->params->field; $required = $manifest->params->required; $key = $manifest->params->aliasmap; $default = isset($manifest->params->default) ? $manifest->params->default : NULL; $value = isset($pub->{$key}) ? $pub->{$key} : NULL; $incomplete = 0; // Parse data in metadata field $data = array(); preg_match_all("#<nb:(.*?)>(.*?)</nb:(.*?)>#s", $pub->metadata, $matches, PREG_SET_ORDER); if (count($matches) > 0) { foreach ($matches as $match) { $data[$match[1]] = \Components\Publications\Helpers\Html::_txtUnpee($match[2]); } } // Metadata field (special treatment) if ($field == 'metadata') { $value = isset($data[$key]) ? $data[$key] : NULL; } // Default value not replaced? if ($default && $value) { if ($default == $value || preg_match('/' . $default . ' (\\(.*\\))/', $value, $matches)) { $status->setError(Lang::txt('Default value needs to be replaced')); } } // Required value not filled? if ($required && !$value) { $status->setError(Lang::txt('Missing ' . $key)); } elseif (!$required && !$value) { $incomplete = 1; } $status->status = $status->getError() ? 0 : 1; $status->status = $incomplete ? 2 : $status->status; return $status; }
/** * Check completion status * * @return object */ public function getStatus($pub = NULL, $manifest = NULL, $elementId = NULL) { // Set block manifest if ($this->_manifest === NULL) { $this->_manifest = $manifest ? $manifest : self::getManifest(); } // Start status $status = new \Components\Publications\Models\Status(); // Get authors if (!isset($pub->_authors)) { $pAuthors = new \Components\Publications\Tables\Author($this->_parent->_db); $pub->_authors = $pAuthors->getAuthors($pub->version_id); $pub->_submitter = $pAuthors->getSubmitter($pub->version_id, $pub->created_by); } // Are authors required? $required = $this->_manifest->params->required; $status->status = $required && (!$pub->_authors || count($pub->_authors) == 0) ? 0 : 1; if ($status->status == 0) { $status->setError('Missing authors'); } return $status; }
/** * Check completion status * * @return object */ public function getStatus($element, $attachments) { $status = new \Components\Publications\Models\Status(); // Get requirements to check against $max = $element->max; $min = $element->min; $role = $element->role; $params = $element->typeParams; $required = $element->required; $counter = count($attachments); if (!$required) { $status->status = $counter ? 1 : 2; return $status; } // Check for correct number of attachments if ($min > 0 && $counter < $min) { if ($counter) { $status->setError(Lang::txt('Need at least ' . $min . ' attachment')); } else { // No Attachments $status->status = 0; return $status; } } elseif ($max > 0 && $counter > $max) { $status->setError(Lang::txt('Maximum ' . $max . ' attachment(s) allowed')); } $status->status = $status->getError() ? 0 : 1; return $status; }
/** * Check completion status * * @return object */ public function getStatus($pub = NULL, $manifest = NULL, $elementId = NULL) { // Start status $status = new \Components\Publications\Models\Status(); $status->status = 1; // Load license class $objL = new \Components\Publications\Tables\License($this->_parent->_db); if ($pub->license_type && $objL->load($pub->license_type)) { $agreement = $pub->params->get('licenseagreement'); // Missing agreement? if ($objL->agreement == 1 && !$agreement) { $status->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_LICENSE_NEED_AGREEMENT')); $status->status = 0; } if ($objL->customizable == 1 && $objL->text && !$pub->license_text) { $status->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_LICENSE_NEED_TEXT')); $status->status = 0; } if ($pub->license_text) { preg_replace('/\\[([^]]+)\\]/', ' ', $pub->license_text, -1, $bingo); if ($bingo) { $status->setError(Lang::txt('Default values need to be substituted')); $status->status = 0; } } } else { $status->status = 0; } return $status; }
/** * Check completion status * * @return object */ public function getStatus($element, $attachments) { $status = new \Components\Publications\Models\Status(); // Get requirements to check against $max = $element->max; $min = $element->min; $role = $element->role; $params = $element->typeParams; $required = $element->required; $counter = count($attachments); // Check for correct number of files if ($min > 0 && $counter < $min) { if ($counter) { $status->setError(Lang::txt('Need at least ' . $min . ' file(s)')); } else { // No files $status->status = 0; if ($required) { return $status; } } } elseif ($max > 0 && $counter > $max) { $status->setError(Lang::txt('Maximum ' . $max . ' files allowed')); } elseif (!self::checkAllowed($attachments, $params->allowed_ext)) { if ($counter && !empty($params->allowed_ext)) { $error = Lang::txt('Error: wrong file type. Allowed file type(s): '); foreach ($params->allowed_ext as $ext) { $error .= ' ' . $ext . ','; } $error = substr($error, 0, strlen($error) - 1); $status->setError($error); } else { $status->setError(Lang::txt('File format not allowed')); } } elseif (!self::checkRequired($attachments, $params->required_ext)) { $status->setError(Lang::txt('Missing a file of required format')); } if (!$required) { $status->status = $counter ? 1 : 2; return $status; } $status->status = $status->getError() ? 0 : 1; return $status; }
/** * Get status for an attachment within publication * * @return object */ public function getStatus($name, $element = NULL, $elementId = 0, $attachments = NULL) { // Load attachment type $type = $this->loadAttach($name); if ($type === false) { $status = new \Components\Publications\Models\Status(); $status->setError(Lang::txt('Attachment type not found')); } else { $attachments = isset($attachments['elements'][$elementId]) ? $attachments['elements'][$elementId] : NULL; // Sort out attachments for this element $attachments = self::getElementAttachments($elementId, $attachments, $name); $status = $type->getStatus($element, $attachments); } // Return status return $status; }
/** * Check completion status * * @param object $element * @param array $attachments * @return object */ public function getStatus($element, $attachments) { $status = new \Components\Publications\Models\Status(); // Get requirements to check against $max = $element->max; $min = $element->min; $role = $element->role; $params = $element->typeParams; $required = $element->required; $counter = count($attachments); $allowed = isset($params->accept) ? $params->accept : NULL; if (!$required) { $status->status = $counter ? 1 : 2; return $status; } // Check for correct number of attachments if ($min > 0 && $counter < $min) { if ($counter) { $status->setError(Lang::txt('Need at least ' . $min . ' attachment')); } else { // No files $status->status = 0; return $status; } } elseif ($max > 0 && $counter > $max) { $status->setError(Lang::txt('Maximum ' . $max . ' attachment(s) allowed')); } elseif (!self::checkAllowed($attachments, $allowed)) { if ($counter && !empty($accept)) { $error = Lang::txt('Error: unacceptable URL. URL should start with: '); foreach ($params->allowed_ext as $ext) { $error .= ' ' . $ext . ','; } $error = substr($error, 0, strlen($error) - 1); $status->setError($error); } } $status->status = $status->getError() ? 0 : 1; return $status; }