public function addFile($file) { Loader::library("file/importer"); Loader::library("mootools/plugin_parser", FRONTEND_DEVELOPER_PACKAGE_HANDLE); $fi = new FileImporter(); $fv = $fi->import($file, basename($file), $this->getExistFile(basename($file))); if (!$fv instanceof FileVersion) { $message = FileImporter::getErrorMessage($result); return $message; } $parser = new MootoolsPluginParser(); $meta = $parser->parse($file); $requireValues = array(); if (is_array($meta["requires"])) { $requires = $meta["requires"]; foreach ($requires as $module) { $option = SelectAttributeTypeOption::getByValue($module); if (empty($option)) { $ak = FileAttributeKey::getByHandle(MOOTOOLS_PLUGIN_DEPENDENCES); $type = SelectAttributeTypeOption::add($ak, $module, true); $value = $type->getSelectAttributeOptionValue(); } else { $value = $option->getSelectAttributeOptionValue(); } $requireValues[$value] = $value; } } $namespaces = explode('.', $meta['name']); $packageName = array_shift($namespaces); $moduleName = str_replace('.js', '', basename($file)); $componentName = $packageName . '/' . $moduleName; $authors = is_array($meta["authors"]) ? join(",", $meta["authors"]) : $meta["authors"]; $license = is_array($meta["license"]) ? join(",", $meta["license"]) : $meta["license"]; $fv->setAttribute(MOOTOOLS_PLUGIN, true); $fv->setAttribute(MOOTOOLS_COMPONENT_NAME, $componentName); $fv->setAttribute(MOOTOOLS_PLUGIN_LICENSE, $license); $fv->setAttribute(MOOTOOLS_PLUGIN_AUTHORS, $authors); $fv->setAttribute(MOOTOOLS_PLUGIN_DEPENDENCES, $requireValues); $fv->setAttribute(MOOTOOLS_PLUGIN_DISPLAY_ORDER, 0); $fv->updateDescription($meta["description"]); $fv->updateTags("mootools\nplugin"); $this->_fileset->addFileToSet($fv); return $fv; }
public function saveOrCreate($ak) { if ($this->tempID != false || $this->ID==0) { return SelectAttributeTypeOption::add($ak, $this->value); } else { $db = Loader::db(); $db->Execute('update atSelectOptions set value = ? where ID = ?', array($this->value, $this->ID)); return SelectAttributeTypeOption::getByID($this->ID); } }
protected function upgradeUserAttributes() { $messages = array(); $db = Loader::db(); $r = $db->Execute('select _UserAttributeKeys.* from _UserAttributeKeys order by displayOrder asc'); while ($row = $r->FetchRow()) { $cleanHandle = preg_replace("/[^A-Za-z0-9\_]/",'',$row['ukHandle']); // remove spaces, chars that'll mess up our index tables $existingAKID = $db->GetOne('select akID from AttributeKeys where akHandle = ?', array($cleanHandle) ); if ($existingAKID < 1) { if(!$row['ukHandle']) continue; $args = array( 'akHandle' => $cleanHandle, 'akIsSearchable' => 1, 'akIsEditable' => 1, 'akName' => $row['ukName'], 'uakIsActive' => ($row['ukHidden']?0:1), 'uakProfileEditRequired' => $row['ukRequired'], 'uakProfileDisplay' => ($row['ukPrivate'] == 0), 'uakRegisterEdit' => $row['ukDisplayedOnRegister'] ); $sttype = $row['ukType']; if ($sttype == 'TEXTAREA') { $sttype = 'TEXT'; } if ($sttype == 'RADIO') { $sttype = 'SELECT'; } $type = AttributeType::getByHandle(strtolower($sttype)); $ak = UserAttributeKey::add($type, $args); if ($sttype == 'SELECT') { $selectOptions = explode("\n", $row['ukValues']); foreach($selectOptions as $so) { if ($so != '') { SelectAttributeTypeOption::add($ak, $so); } } } } else { $ak = UserAttributeKey::getByID($existingAKID); } $r2 = $db->Execute('select * from _UserAttributeValues where ukID = ? and isImported = 0', $row['ukID']); while ($row2 = $r2->FetchRow()) { $ui = UserInfo::getByID($row2['uID']); if(is_object($ui)) { $value = $row2['value']; $ui->setAttribute($ak, $value); } unset($ui); $db->Execute('update _UserAttributeValues set isImported = 1 where ukID = ? and uID = ?', array($row['ukID'], $row2['uID'])); $this->incrementImported(); } unset($ak); unset($row2); $r2->Close(); unset($r2); } unset($row); $r->Close(); unset($r); return $messages; }