示例#1
0
function mapi_id_exists($id, $ofwhat, $env_check = false)
{
    $ids = mapi_available_ids($ofwhat, $env_check);
    if (sizeof($ids) > 0 && in_array($id, $ids)) {
        return true;
    }
    return false;
}
 private function setup_object($record, $new = false)
 {
     if (!$record || !is_object($record)) {
         return null;
     }
     if ($this->title && MValidate::title($this->title)) {
         $record->title = $this->title;
     } else {
         return mapi_report_message('Not a valid content title: ' . $this->title);
     }
     if ($this->license && MValidate::id($this->license) && in_array($this->license, mapi_available_ids('licenses'))) {
         $record->license = $this->license;
     } else {
         return mapi_report_message('Not a valid content license: ' . $this->license);
     }
     $record->name = $this->name;
     if ($new) {
         if (!mapi_check_double('contents', 'name', $this->name)) {
             return mapi_report_message('Content with that name already exists: ' . $this->name);
         }
     }
     if ($this->address && MValidate::address($this->address)) {
         $record->address = $this->address;
     } else {
         return mapi_report_message('Not a valid content address: ' . $this->address);
     }
     if (isset($this->meta_name)) {
         if ($this->meta_name && MValidate::meta_name($this->meta_name)) {
             $record->meta_name = $this->meta_name;
         } else {
             return mapi_report_message('Not a valid meta name: ' . $this->meta_name);
         }
     }
     if (isset($this->meta_value)) {
         if ($this->meta_value && MValidate::meta_value($this->meta_value)) {
             $record->meta_value = $this->meta_value;
         } else {
             return mapi_report_message('Not a valid meta value: ' . $this->meta_value);
         }
     }
     if ($this->lat && MValidate::coord($this->lat)) {
         $record->lat = $this->lat;
     } else {
         return mapi_report_message('Not a valid latitude.');
     }
     if ($this->lng && MValidate::coord($this->lng)) {
         $record->lng = $this->lng;
     } else {
         return mapi_report_message('Not a valid longitude.');
     }
     if ($this->hits && $this->hits > 0) {
         $record->hits = intval($this->hits);
     }
     if ($this->parent) {
         $record->parent = intval($this->parent);
     }
     if ($this->language) {
         $record->language = strval($this->language);
     }
     if ($this->translation && 1 == $this->translation) {
         $record->translation = 1;
     }
     if ($this->enabled && 1 == $this->enabled) {
         $record->enabled = 1;
     } else {
         $record->enabled = 0;
     }
     return true;
 }