public function executeUpdate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod('post') || $request->isMethod('put'));
     $this->forward404Unless($course = CoursePeer::retrieveByPk($request->getParameter('id')), sprintf('Object course does not exist (%s).', $request->getParameter('id')));
     $values = array('edit' => 'true');
     $this->form = new CourseForm($course, $values);
     $c = new Criteria();
     $c->add(CourseDetailPeer::COURSE_ID, $request->getParameter('id'));
     $courseDetail = CourseDetailPeer::doSelectOne($c);
     if ($courseDetail !== null) {
         $this->form2 = new CourseDetailForm($courseDetail);
     } else {
         $this->form2 = new CourseDetailForm(new CourseDetail());
     }
     $c2 = new Criteria();
     $c2->add(CourseDetailPeer::COURSE_ID, $request->getParameter('id'));
     $courseDisAssoc = CourseDisciplineAssociationPeer::doSelectOne($c2);
     if ($courseDisAssoc !== null) {
         $this->form3 = new CourseDisciplineAssociationForm($courseDisAssoc);
     } else {
         $this->form3 = new CourseDisciplineAssociationForm(new CourseDisciplineAssociation());
     }
     $this->submitForm($request, $this->form, $this->form2, $this->form3);
     //at this point the save has failed
     $c = new Criteria();
     //$c->addSelectColumn(CoursePeer::ID);
     $this->course_list = $this->getCourselist($c);
     $this->setTemplate('index');
 }
Example #2
0
 public function executeList()
 {
     $c = new Criteria();
     $c->add(DosagePeer::STATUS, Constant::RECORD_STATUS_DELETED, Criteria::NOT_EQUAL);
     $c->addAscendingOrderByColumn(DosagePeer::TITLE);
     $this->dosages = DosagePeer::doSelect($c);
 }
 public function execute(&$value, &$error)
 {
     $id = $this->getContext()->getRequest()->getParameter('id');
     $name = $value;
     $c = new Criteria();
     $c->add(UserPeer::USERNAME, $name);
     $user = UserPeer::doSelectOne($c);
     $condition = true;
     if ($user) {
         if ($id && $id == $user->getId()) {
             $condition = true;
         } else {
             $error = 'User ' . $user->getUsername() . ' already Exist.';
             $condition = false;
         }
     }
     $roles = RolePeer::doSelect(new Criteria());
     $found = false;
     foreach ($roles as $role) {
         if ($this->getContext()->getRequest()->getParameter($role->getName(), 0) == 1) {
             $found = true;
         }
     }
     if (!$found) {
         $error = 'Please select atleast one role';
         $condition = false;
     }
     return $condition;
 }
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $runData->contextAdd("site", $site);
     // select templates
     $templatesCategory = DB_CategoryPeer::instance()->selectByName("template", $site->getSiteId());
     if ($templatesCategory == null) {
         $runData->contextAdd("noTemplates", true);
         return;
     }
     $c = new Criteria();
     $c->add("category_id", $templatesCategory->getCategoryId());
     $c->addOrderAscending("title");
     $templates = DB_PagePeer::instance()->select($c);
     $runData->contextAdd("templates", $templates);
     // get all categories for the site
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $c->addOrderAscending("replace(name, '_', '00000000')");
     $categories = DB_CategoryPeer::instance()->select($c);
     $runData->contextAdd("categories", $categories);
     // also prepare categories to put into javascript...
     $cats2 = array();
     foreach ($categories as $category) {
         $cats2[] = $category->getFieldValuesArray();
     }
     $runData->ajaxResponseAdd("categories", $cats2);
 }
Example #5
0
 public function configure()
 {
     // Sort
     $activitySortCriteria = new Criteria();
     $activitySortCriteria->addAscendingOrderByColumn(ActivityPeer::NAME);
     $userSortCriteria = new Criteria();
     $userSortCriteria->addAscendingOrderByColumn(UserPeer::FAMILY_NAME);
     // Remove some fields
     //unset($this['usergroup_has_chief_list']);
     // Labels
     $activityItem = ConfigurationHelper::getParameter('Rename', 'activity_label');
     if (is_null($activityItem) || empty($activityItem)) {
         $activityItem = 'Activities';
     }
     $this->widgetSchema->setLabel('usergroup_has_chief_list', 'Leader(s)');
     $this->widgetSchema->setLabel('usergroup_has_user_list', 'Member(s)');
     $this->widgetSchema->setLabel('usergroup_has_activity_list', $activityItem);
     // Validators
     $this->validatorSchema['name'] = new sfXSSValidatorString(array('max_length' => 64));
     // Options
     $this->widgetSchema['usergroup_has_chief_list']->setOption('expanded', true);
     $this->widgetSchema['usergroup_has_chief_list']->setOption('criteria', $userSortCriteria);
     $this->validatorSchema['usergroup_has_chief_list']->setOption('required', true);
     $this->widgetSchema['usergroup_has_user_list']->setOption('expanded', true);
     $this->widgetSchema['usergroup_has_user_list']->setOption('criteria', $userSortCriteria);
     $this->widgetSchema['usergroup_has_activity_list']->setOption('expanded', true);
     $this->widgetSchema['usergroup_has_activity_list']->setOption('criteria', $activitySortCriteria);
     $this->validatorSchema['usergroup_has_activity_list']->setOption('required', true);
 }
 public function saveAuthorArticleList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['author_article_list'])) {
         // somebody has unset this widget
         return;
     }
     if (null === $con) {
         $con = $this->getConnection();
     }
     $c = new Criteria();
     $c->add(AuthorArticlePeer::AUTHOR_ID, $this->object->getPrimaryKey());
     AuthorArticlePeer::doDelete($c, $con);
     $values = $this->getValue('author_article_list');
     if (is_array($values)) {
         foreach ($values as $value) {
             $obj = new AuthorArticle();
             $obj->setAuthorId($this->object->getPrimaryKey());
             $obj->setArticleId($value);
             $obj->save();
         }
     }
 }
Example #7
0
 public function executeRun()
 {
     $this->error = false;
     if (!$this->applicant) {
         $this->error = true;
         $this->messageError = 'Applicant Not Found';
         return false;
     }
     $ta = $this->applicant;
     $this->ta_detail = $ta->getTestApplicantDetail();
     if (!$this->ta_detail) {
         $this->error = true;
         $this->messageError = 'Applicant Detail Not Found';
         return false;
     }
     $cw = new Criteria();
     $cw->add(DepartmentDetailPeer::DEPARTMENT_ID, $ta->getDepartment1());
     $this->department_detail = DepartmentDetailPeer::doSelectOne($cw);
     if (!$this->department_detail) {
         $this->error = true;
         $this->messageError = 'Department not found';
         return false;
     }
     $c = new Criteria();
     $c->add(PaymentJournalPeer::PAYER, $ta->getId());
     $c->add(PaymentJournalPeer::PAYER_TYPE, PaymentJournal::PAYER_TYPE_APPLICANT);
     $payments = PaymentJournalPeer::doSelect($c);
     if (!$payments) {
         $this->error = true;
         $this->messageError = 'Payments not fond';
         return false;
     }
     $this->payments = $payments;
 }
Example #8
0
 public static function getAsistencia($evaluacion, $aspirante)
 {
     $criteria = new Criteria();
     $criteria->add(AsistenciasPeer::EVALUACIONES_ID, $evaluacion, Criteria::EQUAL);
     $criteria->add(AsistenciasPeer::ASPIRANTES_ID, $aspirante, Criteria::EQUAL);
     return self::doSelectOne($criteria);
 }
Example #9
0
 public function saveUsuarioRolList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['usuario_rol_list'])) {
         // somebody has unset this widget
         return;
     }
     if (is_null($con)) {
         $con = $this->getConnection();
     }
     $c = new Criteria();
     $c->add(UsuarioRolPeer::FK_ROL_ID, $this->object->getPrimaryKey());
     UsuarioRolPeer::doDelete($c, $con);
     $values = $this->getValue('usuario_rol_list');
     if (is_array($values)) {
         foreach ($values as $value) {
             $obj = new UsuarioRol();
             $obj->setFkRolId($this->object->getPrimaryKey());
             $obj->setFkUsuarioId($value);
             $obj->save();
         }
     }
 }
 public static function getAllCommentsForResource($resource, $con = null)
 {
     $c = new Criteria();
     $c->add(sfEmendCommentPeer::URL, $resource);
     $c->add(sfEmendCommentPeer::IS_PUBLIC, 1);
     return sfEmendCommentPeer::doSelect($c, $con);
 }
 public function saveProductHasColorList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['product_has_color_list'])) {
         // somebody has unset this widget
         return;
     }
     if (null === $con) {
         $con = $this->getConnection();
     }
     $c = new Criteria();
     $c->add(ProductHasColorPeer::COLOR_ID, $this->object->getPrimaryKey());
     ProductHasColorPeer::doDelete($c, $con);
     $values = $this->getValue('product_has_color_list');
     if (is_array($values)) {
         foreach ($values as $value) {
             $obj = new ProductHasColor();
             $obj->setColorId($this->object->getPrimaryKey());
             $obj->setProductId($value);
             $obj->save();
         }
     }
 }
 public function doSaveMedia($v)
 {
     if ($v == null) {
         $image = $this->getImagePath();
         if ($this->isNew) {
             $content = file_get_contents(sfConfig::get('sf_root_dir') . '/public_html' . $image);
             $size = getimagesize(sfConfig::get('sf_root_dir') . '/public_html' . $image);
         } else {
             return $this->getObject()->getImagesId();
         }
     } else {
         $content = file_get_contents($v->getTempName());
         $size = getimagesize($v->getTempName());
     }
     $hash = md5($content);
     $criteria = new Criteria();
     $criteria->add(ImagesPeer::CONTENT_HASH, $hash);
     $obj = ImagesPeer::doSelectOne($criteria);
     try {
         if (empty($obj)) {
             $obj = new Images();
             $obj->setNameDownloadedFile($v->getOriginalName())->setNameFileForPage($v->getOriginalName())->setTypeImg($v->getType())->setHeight($size[2])->setWidth($size[1])->setContentHash($hash . '.jpg')->setContent(base64_encode($content))->setCreatedAt(date("Y-m-d H:i"))->setUpdatedAt(date("Y-m-d H:i"))->save();
         }
     } catch (Exception $e) {
         echo "stdfdfdfdfrt";
         die;
     }
     $criteria = new Criteria();
     $criteria->add(ImagesPeer::CONTENT_HASH, $obj->getContentHash());
     $obj = ImagesPeer::doSelectOne($criteria);
     return $obj->getId();
 }
 public function saveJobeetCategoryAffiliateList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['jobeet_category_affiliate_list'])) {
         // somebody has unset this widget
         return;
     }
     if (null === $con) {
         $con = $this->getConnection();
     }
     $c = new Criteria();
     $c->add(JobeetCategoryAffiliatePeer::CATEGORY_ID, $this->object->getPrimaryKey());
     JobeetCategoryAffiliatePeer::doDelete($c, $con);
     $values = $this->getValue('jobeet_category_affiliate_list');
     if (is_array($values)) {
         foreach ($values as $value) {
             $obj = new JobeetCategoryAffiliate();
             $obj->setCategoryId($this->object->getPrimaryKey());
             $obj->setAffiliateId($value);
             $obj->save();
         }
     }
 }
Example #14
0
 public static function getallByClassRoom($classroom_id)
 {
     $c = new Criteria();
     $c->addJoin(ClassroomResourcesPeer::RESOURCE_ID, self::ID);
     $c->add(ClassroomResourcesPeer::CLASSROOM_ID, $classroom_id);
     return self::doSelect($c);
 }
 /**
  * Get repository by URI
  * @param string $url the url of the repository to find
  * @return QubitQuery collection of OAI-PMH Repositories
  */
 public static function getByURI($URI)
 {
     $criteria = new Criteria();
     $criteria->add(QubitOaiRepository::URI, $URI, Criteria::LIKE);
     $criteria->addAscendingOrderByColumn(QubitOaiRepository::NAME);
     return self::get($criteria);
 }
 public function testStaticDoSoftDelete()
 {
     $t1 = new Table4();
     $t1->save();
     $t2 = new Table4();
     $t2->save();
     $t3 = new Table4();
     $t3->save();
     // softDelete with a criteria
     $c = new Criteria();
     $c->add(Table4Peer::ID, $t1->getId());
     Table4Peer::doSoftDelete($c);
     Table4Peer::disableSoftDelete();
     $this->assertEquals(3, Table4Peer::doCount(new Criteria()), 'doSoftDelete() keeps deleted record in the database');
     Table4Peer::enableSoftDelete();
     $this->assertEquals(2, Table4Peer::doCount(new Criteria()), 'doSoftDelete() marks deleted record as deleted');
     // softDelete with a value
     Table4Peer::doSoftDelete(array($t2->getId()));
     Table4Peer::disableSoftDelete();
     $this->assertEquals(3, Table4Peer::doCount(new Criteria()), 'doSoftDelete() keeps deleted record in the database');
     Table4Peer::enableSoftDelete();
     $this->assertEquals(1, Table4Peer::doCount(new Criteria()), 'doSoftDelete() marks deleted record as deleted');
     // softDelete with an object
     Table4Peer::doSoftDelete($t3);
     Table4Peer::disableSoftDelete();
     $this->assertEquals(3, Table4Peer::doCount(new Criteria()), 'doSoftDelete() keeps deleted record in the database');
     Table4Peer::enableSoftDelete();
     $this->assertEquals(0, Table4Peer::doCount(new Criteria()), 'doSoftDelete() marks deleted record as deleted');
 }
Example #17
0
 public function executeDelete()
 {
     $userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', null, 'subscriber');
     $this->bikeid = $this->getRequestParameter('bikeid');
     if ($this->getRequest()->getMethod() == sfRequest::POST) {
         //delete user_stat and equipment
         $c = new Criteria();
         $c->add(UserStatsPeer::USER_ID, $userId);
         $c->add(UserStatsPeer::BIKE_ID, $this->bikeid);
         $s = UserStatsPeer::doSelectJoinAll($c);
         foreach ($s as $stat) {
             foreach ($stat->getUserStatEquips() as $equip) {
                 $equip->delete();
             }
             $stat->delete();
         }
         //move equipment to shelf
         $c = new Criteria();
         $c->add(UserEquipementPeer::USER_ID, $userId);
         $c->add(UserEquipementPeer::BIKE_ID, $this->bikeid);
         $equip = UserEquipementPeer::doSelect($c);
         foreach ($equip as $e) {
             $e->setBikeId(null);
             $e->save();
         }
         //now delete bike
         $user_bikes = UserBikesPeer::retrieveByPk($this->bikeid);
         $user_bikes->delete();
         return $this->redirect('userbike/index');
     }
 }
Example #18
0
 public static function cleanup($days)
 {
     $criteria = new Criteria();
     $criteria->add(self::IS_ACTIVATED, false);
     $criteria->add(self::CREATED_AT, time() - 86400 * $days, Criteria::LESS_THAN);
     return self::doDelete($criteria);
 }
Example #19
0
 /**
  * Get objects by kuser and user role IDs
  * @param int $kuserId
  * @param int $userRoleId
  * @return array Array of selected KuserToUserRole Objects
  */
 public static function getByKuserAndUserRoleIds($kuserId, $userRoleId)
 {
     $c = new Criteria();
     $c->addAnd(self::KUSER_ID, $kuserId, Criteria::EQUAL);
     $c->addAnd(self::USER_ROLE_ID, $userRoleId, Criteria::EQUAL);
     return self::doSelect($c);
 }
Example #20
0
 public function updateAction()
 {
     $criteria = new Criteria("person");
     $person = PersonData::getById($_POST["id"]);
     $criteria->update(array("no" => "\"{$_POST['no']}\"", "name" => "\"{$_POST['name']}\"", "lastname" => "\"{$_POST['lastname']}\"", "job" => "\"{$_POST['job']}\"", "phone1" => "\"{$_POST['phone1']}\"", "phone2" => "\"{$_POST['phone2']}\"", "address1" => "\"{$_POST['address1']}\"", "address2" => "\"{$_POST['address2']}\"", "email1" => "\"{$_POST['email1']}\"", "email2" => "\"{$_POST['email2']}\"", "team_id" => "\"{$_POST['team_id']}\"", "category_id" => "\"{$_POST['category_id']}\""), "id=" . $_POST["id"]);
     Core::redir("./?r=index/people");
 }
Example #21
0
 /**
  * Retrieve the server object of the current data center
  *
  * @param      string $server server name
  * @param      PropelPDO $con the connection to use
  * @return     SphinxLogServer
  */
 public static function retrieveByLocalServer($server, PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(SphinxLogServerPeer::SERVER, $server);
     $criteria->add(SphinxLogServerPeer::DC, kDataCenterMgr::getCurrentDcId());
     return SphinxLogServerPeer::doSelectOne($criteria, $con);
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $selector = $request->getParameter('select');
     $selector = $selector == "" ? 'execution' : $selector;
     $user = $this->getUser()->getAttribute('s_current_user', null);
     if ($user != null) {
         $this->selector = $selector;
         $criterio = new Criteria();
         $criterio->add(TreeScPeer::USER_ID, $user->getId());
         $criterio->add(TreeScPeer::FLAG, 1);
         $list_tree = TreeScPeer::doSelect($criterio);
         $this->list = $list_tree;
         $criteria = new Criteria();
         $criteria->add(TreeScPeer::USER_ID, $user->getId());
         $criteria->add(TreeScPeer::PRODUCCION, '%production%', Criteria::LIKE);
         $criteria->add(TreeScPeer::FLAG, 1);
         $user_tree = TreeScPeer::doSelect($criteria);
         $this->lista_tree_user = $user_tree;
         $criteria->clear();
         // indicadores a los cuales este usuario esta com responsables
         $criteria->add(IndicatorsScPeer::RESPONSABLE_ID, $user->getId());
         $criteria->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE);
         $criteria->add(TreeScPeer::FLAG, 1);
         $criteria->add(TreeScPeer::PRODUCCION, '%production%', Criteria::LIKE);
         $criteria->addJoin(TreeScPeer::ID, IndicatorsScPeer::TREE_ID);
         $criteria->addGroupByColumn(IndicatorsScPeer::TREE_ID);
         $user_indicators = IndicatorsScPeer::doSelect($criteria);
         $criteria->clear();
         $this->lista_indicators_user = $user_indicators;
         return sfView::SUCCESS;
     } else {
         return sfView::ERROR;
     }
 }
Example #23
0
 public static function retrieveByUuid($value)
 {
     $c = new Criteria();
     $c->add(self::UUID, $value);
     $c->setIgnoreCase(true);
     return self::doSelectOne($c);
 }
 protected function loadItems()
 {
     $c = new Criteria();
     $c->add("returnBond", "", "!=");
     $c->add('status', 'validated');
     $this->items = $this->site->findAll($c, "siteId, url, returnBond");
 }
Example #25
0
 public function saveSubcategoriesHasFitxersList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['subcategories_has_fitxers_list'])) {
         // somebody has unset this widget
         return;
     }
     if (is_null($con)) {
         $con = $this->getConnection();
     }
     $c = new Criteria();
     $c->add(SubcategoriesHasFitxersPeer::FITXERS_FITXERSID, $this->object->getPrimaryKey());
     SubcategoriesHasFitxersPeer::doDelete($c, $con);
     $values = $this->getValue('subcategories_has_fitxers_list');
     if (is_array($values)) {
         foreach ($values as $value) {
             $obj = new SubcategoriesHasFitxers();
             $obj->setFitxersFitxersid($this->object->getPrimaryKey());
             $obj->setSubcategoriesIdsubcategories($value);
             $obj->save();
         }
     }
 }
Example #26
0
 public static function getReportCount()
 {
     $c = new Criteria();
     $c->add(self::REPORTS, 0, Criteria::GREATER_THAN);
     $c = self::addPermanentTagToCriteria($c);
     return self::doCount($c);
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = null;
     $partnerId = $this->getRequestParameter("partnerId", null);
     $uiConfId = $this->getRequestParameter("uiConfId", null);
     $page = $this->getRequestParameter("page", 1);
     if ($partnerId !== null && $partnerId !== "") {
         $pageSize = 50;
         $c = new Criteria();
         $c->add(widgetPeer::PARTNER_ID, $partnerId);
         if ($uiConfId) {
             $c->add(widgetPeer::UI_CONF_ID, $uiConfId);
         }
         $c->addDescendingOrderByColumn(widgetPeer::CREATED_AT);
         $total = widgetPeer::doCount($c);
         $lastPage = ceil($total / $pageSize);
         $c->setOffset(($page - 1) * $pageSize);
         $c->setLimit($pageSize);
         $widgets = widgetPeer::doSelect($c);
     } else {
         $total = 0;
         $lastPage = 0;
         $widgets = array();
     }
     $this->uiConfId = $uiConfId;
     $this->page = $page;
     $this->lastPage = $lastPage;
     $this->widgets = $widgets;
     $this->partner = PartnerPeer::retrieveByPK($partnerId);
     $this->partnerId = $partnerId;
 }
Example #28
0
 public function loadListFromTable($listName)
 {
     $tableName = $listName;
     // table must have columns: key, text and sort_index
     // the row with option_id = null indicates the "please select" value
     $peerName = $peerName = "DB_" . capitalizeFirstLetter(underscoreToLowerCase($tableName)) . "Peer";
     $peer = new $peerName();
     $c = new Criteria();
     $c->add("key", null);
     $pleaseSelectOption = $peer->selectOne($c);
     $c = new Criteria();
     $c->add("key", null, "!=");
     $c->addOrderAscending("sort_index");
     $c->addOrderAscending("text");
     $options = $peer->select($c);
     if ($pleaseSelectOption != null) {
         $this->pleaseSelectValues["{$listName}"] = $pleaseSelectOption->getText();
     } else {
         // try SELECT_PLEASE_SELECT from the messages...
         $text = MessageResolver::instance()->message("SELECT_PLEASE_SELECT");
         if ($text != null) {
             $this->pleaseSelectValues["{$listName}"] = $text;
         }
     }
     $out = array();
     foreach ($options as $option) {
         $optionKey = $option->getKey();
         $out["{$optionKey}"] = $option->getText();
     }
     $this->storage["{$listName}"] = $out;
 }
Example #29
0
 public static function create($isoLang = 'pt_BR')
 {
     $xmlDoc = new DOMDocument('1.0', 'utf-8');
     $xmlDoc->formatOutput = true;
     $culture = $xmlDoc->createElement($isoLang);
     $culture = $xmlDoc->appendChild($culture);
     $criteria = new Criteria();
     $criteria->add(TagI18n::TABLE . '.' . TagI18n::ISOLANG, $isoLang);
     $objTagI18n = new TagI18nPeer();
     $arrayObjTagI18n = $objTagI18n->doSelect($criteria);
     if (!is_object($arrayObjTagI18n) && count($arrayObjTagI18n == 0)) {
         $log = new Log();
         $log->setLog(__FILE__, 'There are no tags with that language ' . $isoLang, true);
         throw new Exception('There are no tags with that language ' . $isoLang);
     }
     foreach ($arrayObjTagI18n as $objTagI18nPeer) {
         $item = $xmlDoc->createElement('item');
         $item->setAttribute('idTagI18n', $objTagI18nPeer->getIdTagI18n());
         $item = $culture->appendChild($item);
         $title = $xmlDoc->createElement('tag', utf8_encode($objTagI18nPeer->getTag()));
         $title = $item->appendChild($title);
         $link = $xmlDoc->createElement('i18n', utf8_encode($objTagI18nPeer->getTranslate()));
         $link = $item->appendChild($link);
     }
     //header("Content-type:application/xml; charset=utf-8");
     $file = PATH . PATH_I18N . $isoLang . '.xml';
     try {
         file_put_contents($file, $xmlDoc->saveXML());
     } catch (Exception $e) {
         $log = new Log();
         $log->setLog(__FILE__, 'Unable to write the XML file I18n ' . $e->getMessage(), true);
     }
     return true;
 }
Example #30
0
 public function executeVerify()
 {
     $this->redirectIf($this->getUser()->isAuthenticated(), 'ucp/index');
     $file = $this->getRequestParameter('file');
     $c = new Criteria();
     $c->add(BlogPeer::FILE, $file);
     $blog = BlogPeer::doSelectOne($c);
     if ($blog && !$blog->getVerified()) {
         $blog_url = $blog->getUrl();
         if ($blog_url[strlen($blog_url) - 1] != '/') {
             $blog_url .= '/';
         }
         $url = $blog_url . $file . '.html';
         $test1 = @fopen($url, 'r') !== false;
         $test2 = false;
         if (!$test1) {
             $contents = file_get_contents($blog_url);
             $test2 = preg_match('/<meta name="verify-phppl" content="' . $file . '" \\/>/im', $contents);
         }
         if ($test1 || $test2) {
             $blog->setVerified(true);
             $blog->save();
             $this->setFlash('verified', true);
             $this->redirect('ucp/index');
         } else {
             $this->url = $url;
             $this->file = $file;
             return sfView::ERROR;
         }
     } else {
         $this->redirect('@homepage');
     }
 }