Beispiel #1
0
 public function setCommitInfos($commitInfos)
 {
     $explodedInfos = strlen($commitInfos) > 0 ? explode(' ', $commitInfos, 2) : array();
     if (count($explodedInfos) == 2) {
         $this->setLastChangeCommitDesc($explodedInfos[1]);
         $profile = ProfilePeer::getProfileByEmail($explodedInfos[0]);
         if ($profile) {
             $this->setLastChangeCommitUser($profile->getSfGuardUserId());
         }
     }
     return $this;
 }
 public function down()
 {
     $option = array('length' => 4);
     $this->changeColumn('profile', 'value_min', 'integer', $option);
     $this->changeColumn('profile', 'value_max', 'integer', $option);
     $birthday = ProfilePeer::retrieveByName('birthday');
     if ($birthday) {
         $birthday->setValueMin(null);
         $birthday->setValueMax(null);
         $birthday->save();
     }
 }
 /**
  * @see sfFilter
  */
 public function execute($filterChain)
 {
     if ($this->isFirstCall()) {
         $apiKey = $this->getContext()->getRequest()->getParameter('apikey');
         $profile = ProfilePeer::retrieveByApiKey($apiKey);
         if (null !== $profile) {
             $this->context->getUser()->signIn($profile->getSfGuardUser());
         } else {
             throw new RuntimeException('Api key is not authorized');
         }
     }
     parent::execute($filterChain);
 }
    public function getAllProfileProperties($forExport = false)
    {
        $foo = array();
        if ('schema' === $this->type) {
            $profile = \ProfilePeer::retrieveByPK(1);
        } else {
            $profile = \ProfilePeer::retrieveByPK(2);
        }
        $c = new \Criteria();
        $c->addAscendingOrderByColumn(\ProfilePropertyPeer::EXPORT_ORDER);

        if ( $forExport )
        {
            $c->add( \ProfilePropertyPeer::IS_IN_EXPORT, true );
        }
        $results   = $profile->getProfilePropertys($c);
        $languages = $this->getLanguages();
        /** @var \profileProperty $result */
        foreach ( $results as $result )
        {
            foreach ( $languages as $language )
            {
                $foo[0][$result->getId()][$language] = 1;
            }
        }

        $bar = self::buildColumnArray( $foo );

        return $bar;
    }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(ProfilePeer::ID, $pks, Criteria::IN);
         $objs = ProfilePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
function run_import_marc_vocabulary($task, $args)
{


    //check the argument counts
    if (count($args) < 1) {
        throw new Exception('You must provide a vocabulary type.');
    }

    if (count($args) < 2) {
        throw new Exception('You must provide a file name.');
    }

    if (count($args) < 3) {
        throw new Exception('You must provide a vocabulary id.');
    }

    //set the arguments
    $type          = strtolower($args[0]);
    $filePath      = $args[1];
    $id            = $args[2];
    $deleteMissing = (isset($args[3]) && ("-d" == $args[3]));

    //do some basic validity checks

    if (! in_array($type, array("schema", "vocab", "vocabulary"))) {
        throw new Exception('You must import into a schema or a vocab');
    }

    if ("vocabulary" == $type) {
        $type = "vocab";
    }

    if (! is_numeric($id)) {
        throw new Exception('You must provide a valid ID');
    }

    //does the file exist?
    if (! file_exists($filePath)) {
        throw new Exception('You must supply a valid file to import: ' . $filePath);
    }

    //is the file a valid type?
    if (preg_match('/^.+\.([[:alpha:]]{2,4})$/', $filePath, $matches)) {
        if (! in_array(strtolower($matches[1]), array("json", "rdf", "csv", "xml"))) {
            throw new Exception('You must provide a valid file type based on the extension');
        }
    } else {
        throw new Exception("File type cannot be determined from the file extension");
    }

    $fileType = $matches[1];

    //is the object a valid object?
    if ('vocab' == $type) {
        $vocabObj = VocabularyPeer::retrieveByPK($id);
        if (is_null($vocabObj)) {
            throw new Exception('Invalid vocabulary ID');
        }

        //set some defaults
        $baseDomain = $vocabObj->getBaseDomain();
        $language   = $vocabObj->getLanguage();
        $statusId   = $vocabObj->getStatusId();

        //get a skos property id map
        $skosMap = SkosPropertyPeer::getPropertyNames();

        //there has to be a hash or a slash
        $tSlash = preg_match('@(/$)@i', $vocabObj->getUri()) ? '' : '/';
        $tSlash = preg_match('/#$/', $vocabObj->getUri()) ? '' : $tSlash;
    } else {
        $schemaObj = SchemaPeer::retrieveByPK($id);
        if (is_null($schemaObj)) {
            throw new Exception('Invalid schema ID');
        }

        //set some defaults
        $baseDomain = $schemaObj->getUri();
        $language   = $schemaObj->getLanguage();
        $statusId   = $schemaObj->getStatusId();

        //get a element set property id map
        $profileId  = 1;
        $profile    = ProfilePeer::retrieveByPK($profileId);
        $elementMap = $profile->getAllProperties();

        //there has to be a hash or a slash
        $tSlash = preg_match('@(/$)@i', $baseDomain) ? '' : '/';
        $tSlash = preg_match('/#$/', $baseDomain) ? '' : $tSlash;
    }

    //     insert jon's user id
    $userId = 36;

    /* From here on the process is the same regardless of UI */

    //execute
    //     parse file to get the fields/columns and data
    $file = fopen($filePath, "r");
    if (! $file) {
        throw new Exception("Can't read supplied file");
    }

    //     check to see if file has been uploaded before
    //          check import history for file name
    $importHistory = FileImportHistoryPeer::retrieveByLastFilePath($filePath);
    //          if reimport
    //               get last import history for filename
    //               unserialize column map
    //               match column names to AP based on map
    //     look for matches in unmatched field/column names to AP (ideal)
    //     csv table of data --
    //          row1: parsed field names/column headers
    //          row2: select dropdown with available fields from object AP (pre-select known matches)
    //                each select identified by column number
    //          row3: display datatype of selected field (updated dynamically when field selected)
    //          row4-13: first 10 rows of parsed data from file
    //     require a column that can match to 'URI' (maybe we'll allow an algorithm later)
    //     require columns that are required by AP
    //     on reimport there should be a flag to 'delete missing properties' from the current data
    //     note: at some point there will be a reimport process that allows URI changing
    //          this will require that there be an OMR identifier embedded in the incoming data

    switch ($fileType) {
        case "csv":
            try {
                $reader = new aCsvReader($filePath);
            } catch(Exception $e) {
                throw new Exception("Not a happy CSV file!");
            }

            if ('vocab' == $type) {
                // Get array of heading names found
                $headings = $reader->getHeadings();
                $fields   = ConceptPeer::getFieldNames();

                //set the map
                //      $map[] = array("property" => "Uri", "column" => "URILocal");
                //      $map[] = array("property" => "prefLabel", "column" => "skos:prefLabel");
                //      $map[] = array("property" => "definition", "column" => "skos:definition");
                //      $map[] = array("property" => "notation", "column" => "skos:notation");
                //      $map[] = array("property" => "scopeNote", "column" => "skos:scopeNote");

                $map = array(
                  "uri"        => "URILocal",
                  "prefLabel"  => "skos:prefLabel",
                  "definition" => "skos:definition",
                  "notation"   => "skos:notation",
                  "scopeNote"  => "skos:scopeNote"
                );

                $rows = 0;

                //executeImport:

                //    serialize the column map
                try {
                    while ($row = $reader->getRow()) {
                        $rows ++;
                        //        lookup the URI (or the OMR ID if available) for a match
                        $uri        = $baseDomain . $row[$map["uri"]];
                        $concept    = ConceptPeer::getConceptByUri($uri);
                        $updateTime = time();
                        $language   = (isset($map['language'])) ? $row[$map['language']] : $vocabObj->getLanguage();

                        if (! $concept) {
                            //          create a new concept or element
                            $concept = new Concept();
                            $concept->setVocabulary($vocabObj);
                            $concept->setUri($uri);
                            /**
                             * @todo Need to handle updates for topconcept here, just like language
                             **/
                            $concept->setIsTopConcept(false);
                            $concept->updateFromRequest(
                                    $userId,
                                      fixMarcEncoding(rtrim($row[$map['prefLabel']])),
                                      $language,
                                      $statusId
                            );
                        } //don't update the concept if the preflabel matches
                        else if ($row[$map['prefLabel']] != $concept->getPrefLabel()) {
                            $concept->updateFromRequest($userId, fixMarcEncoding(rtrim($row[$map['prefLabel']])));
                        }

                        //there needs to be a language to lookup the properties unless it's an objectProperty
                        $rowLanguage = (isset($map['language'])) ? $row[$map['language']] : $concept->getLanguage();

                        foreach ($map as $key => $value) {
                            //we skip because we already did them
                            if (! in_array($key, array('uri', 'prefLabel', 'language'))) {
                                $skosId = $skosMap[$key];
                                //check to see if the property already exists
                                $property =
                                  ConceptPropertyPeer::lookupProperty($concept->getId(), $skosId, $rowLanguage);

                                //create a new property for each unmatched column
                                if (! empty($row[$value])) {
                                    if (! $property) {
                                        $property = new ConceptProperty();
                                        $property->setCreatedUserId($userId);
                                        $property->setConceptId($concept->getId());
                                        $property->setCreatedAt($updateTime);
                                        $property->setSkosPropertyId($skosId);
                                    }

                                    if (($row[$value] != $property->getObject()) ||
                                        ($rowLanguage != $property->getLanguage())
                                    ) {
                                        /**
                                         * @todo We need a check here for skos objectproperties and handle differently
                                         **/
                                        if ($rowLanguage != $property->getLanguage()) {
                                            $property->setLanguage($rowLanguage);
                                        }
                                        if ($row[$value] != $property->getObject()) {
                                            $property->setObject(fixMarcEncoding(rtrim($row[$value])));
                                        }
                                        $property->setUpdatedUserId($userId);
                                        $property->setUpdatedAt($updateTime);
                                        $property->save();
                                    }
                                } //the row value is empty
                                else if ($deleteMissing && $property) {
                                    $property->delete();
                                }
                            }
                        }

                        //          else
                        //               lookup and update concept or element
                        //               lookup and update each property
                        //          update the history for each property, action is 'import', should be a single timestamp for all (this should be automatic)
                        //          if 'delete missing properties' is true
                        //               delete each existing, non-required property that wasn't updated by the import
                    }
                } catch(Exception $e) {
                    //          catch
                    //            if there's an error of any kind, write to error log and continue
                    echo "Error on row: " . $rows . ", " . $uri . "\n" . $e . "\n";
                    continue;
                }
                $objects = $vocabObj->countConcepts();
            } else //it's an element set
            {
                $map  = array(
                  "uri"        => "uriLocalPart",
                  "name"       => "reg:name",
                  "definition" => "skos:definition",
                  "label"      => "rdfs:label",
                  "note"       => array("tag" => "tagCap", "ind1" => "ind1Cap", "ind2" => "ind2Cap", "sub" => "subCap")
                );
                $rows = 0;

                //executeImport:
                //    serialize the column map
                try {
                    while ($row = $reader->getRow()) {
                        //        lookup the URI (or the OMR ID if available) for a match

                        //There always has to be a URI on either update or create
                        if (! isset($row[$map["uri"]])) {
                            throw new Exception('Missing URI for row: ' . $reader->getRowCount());
                            continue;
                        }

                        $rows ++;
                        $uri         = $baseDomain . $tSlash . $row[$map["uri"]];
                        $property    = SchemaPropertyPeer::retrieveByUri($uri);
                        $updateTime  = time();
                        $rowLanguage = (isset($map['language'])) ? $row[$map['language']] : $language;
                        $rowStatusId = (isset($map['status'])) ? $row[$map['status']] : $statusId;

                        if (! $property) {
                            //          create a new property
                            /** @var SchemaProperty * */
                            $property = new SchemaProperty();
                            $property->setSchema($schemaObj);
                            $property->setUri($uri);
                            $property->setCreatedUserId($userId);
                            $property->setCreatedAt($updateTime);
                        }

                        $property->setLanguage($rowLanguage);
                        $property->setStatusId($rowStatusId);
                        $property->setUpdatedUserId($userId);
                        $property->setUpdatedAt($updateTime);

                        if (isset($row[$map["label"]])) {
                            $property->setLabel($row[$map["label"]]);
                        }

                        if (isset($row[$map["name"]])) {
                            $property->setName($row[$map["name"]]);
                        }

                        if (isset($row[$map["definition"]])) {
                            $property->setDefinition($row[$map["definition"]]);
                        }

                        if (is_array($map["note"])) {
                            $note = '';
                            foreach ($map["note"] as $key => $value) {
                                $caption = ! empty($row[$value]) ? " (" . $row[$value] . ")" : ' (no caption)';
                                $note .= ! empty($row[$key]) ? $key . ": " . $row[$key] . $caption . "<br />" : "";
                            }
                            $property->setNote($note);
                        } else {
                            if (isset($row[$map["note"]])) {
                                $property->setNote($row[$map["note"]]);
                            }
                        }
                        $property->saveSchemaProperty($userId);

                        /**
                         * @todo Need to handle domain and range
                         **/

                        foreach ($map as $key => $value) {
                            //we skip because we already did them
                            if (! in_array(
                              $key,
                              array('uri', 'status', 'language', 'label', 'name', 'definition', 'comment', 'note')
                            )
                            ) {
                                $elementId = $elementMap[$key];
                                //check to see if the property already exists
                                //note that this also checks the object value as well, so there's no way to update or delete an existing triple
                                //the sheet would have to conatin the identifier for the triple
                                $element = SchemaPropertyElementPeer::lookupElement(
                                                                    $schemaObj->getId(),
                                                                      $elementId,
                                                                      $map[$value]
                                );

                                //create a new property for each unmatched column
                                if (! empty($row[$value])) {
                                    if (! $element) {
                                        $element = new SchemaPropertyElement();
                                        $element->setCreatedUserId($userId);
                                        $element->setCreatedAt($updateTime);
                                        $element->setProfilePropertyId($elementId);
                                    }

                                    if (($row[$value] != $element->getObject()) ||
                                        ($rowLanguage != $element->getLanguage())
                                    ) {
                                        /**
                                         * @todo We need a check here for objectproperties and handle differently
                                         **/
                                        if ($rowLanguage != $element->getLanguage()) {
                                            $element->setLanguage($rowLanguage);
                                        }
                                        if ($row[$value] != $element->getObject()) {
                                            $element->setObject($row[$value]);
                                        }
                                        $element->setUpdatedUserId($userId);
                                        $element->setUpdatedAt($updateTime);
                                        $element->save();
                                    }
                                } //the row value is empty
                                else if ($deleteMissing && $element) {
                                    $element->delete();
                                }
                            }
                        }

                        //          else
                        //               lookup and update concept or element
                        //               lookup and update each property
                        //          update the history for each property, action is 'import', should be a single timestamp for all (this should be automatic)
                        //          if 'delete missing properties' is true
                        //               delete each existing, non-required property that wasn't updated by the import
                    }
                } catch(Exception $e) {
                    //          catch
                    //            if there's an error of any kind, write to error log and continue
                    echo "Error on row: " . $rows . ", " . $uri . "\n" . $e . "\n";
                    continue;
                }
                $objects = $schemaObj->countSchemaPropertys();
            }
            //     save the import history file (match timestamp to history entries)
            break;
        case "json":
            break;
        case "rdf":
            break;
        case "xml":
            break;
        default:
    }

    /* output to stdout*/
    //          number of objects imported (link to history, filtered on timestamp of import)
    echo "File:" . $filePath . ";\n     Objects imported: " . $objects . "; Rows read: " . $rows . "\n";
    //          number of errors (link to error log)

}
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Agent is new, it will return
  * an empty collection; or if this Agent has previously
  * been saved, it will retrieve related Profiles from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Agent.
  */
 public function getProfilesJoinStatus($criteria = null, $con = null)
 {
     // include the Peer class
     include_once 'lib/model/om/BaseProfilePeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collProfiles === null) {
         if ($this->isNew()) {
             $this->collProfiles = array();
         } else {
             $criteria->add(ProfilePeer::AGENT_ID, $this->getId());
             $this->collProfiles = ProfilePeer::doSelectJoinStatus($criteria, $con);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(ProfilePeer::AGENT_ID, $this->getId());
         if (!isset($this->lastProfileCriteria) || !$this->lastProfileCriteria->equals($criteria)) {
             $this->collProfiles = ProfilePeer::doSelectJoinStatus($criteria, $con);
         }
     }
     $this->lastProfileCriteria = $criteria;
     return $this->collProfiles;
 }
Beispiel #8
0
 /**
  * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
  * feature (like MySQL or SQLite).
  *
  * This method is not very speedy because it must perform a query first to get
  * the implicated records and then perform the deletes by calling those Peer classes.
  *
  * This method should be used within a transaction if possible.
  *
  * @param      Criteria $criteria
  * @param      PropelPDO $con
  * @return     int The number of affected rows (if supported by underlying database driver).
  */
 protected static function doOnDeleteCascade(Criteria $criteria, PropelPDO $con)
 {
     // initialize var to track total num of affected rows
     $affectedRows = 0;
     // first find the objects that are implicated by the $criteria
     $objects = sfGuardUserPeer::doSelect($criteria, $con);
     foreach ($objects as $obj) {
         // delete related Profile objects
         $criteria = new Criteria(ProfilePeer::DATABASE_NAME);
         $criteria->add(ProfilePeer::SF_GUARD_USER_ID, $obj->getId());
         $affectedRows += ProfilePeer::doDelete($criteria, $con);
         // delete related sfGuardUserPermission objects
         $criteria = new Criteria(sfGuardUserPermissionPeer::DATABASE_NAME);
         $criteria->add(sfGuardUserPermissionPeer::USER_ID, $obj->getId());
         $affectedRows += sfGuardUserPermissionPeer::doDelete($criteria, $con);
         // delete related sfGuardUserGroup objects
         $criteria = new Criteria(sfGuardUserGroupPeer::DATABASE_NAME);
         $criteria->add(sfGuardUserGroupPeer::USER_ID, $obj->getId());
         $affectedRows += sfGuardUserGroupPeer::doDelete($criteria, $con);
         // delete related sfGuardRememberKey objects
         $criteria = new Criteria(sfGuardRememberKeyPeer::DATABASE_NAME);
         $criteria->add(sfGuardRememberKeyPeer::USER_ID, $obj->getId());
         $affectedRows += sfGuardRememberKeyPeer::doDelete($criteria, $con);
     }
     return $affectedRows;
 }
 /**
  * Selects a collection of ProfileProperty objects pre-filled with all related objects except ProfilePropertyRelatedByInverseProfilePropertyId.
  *
  * @return array Array of ProfileProperty objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptProfilePropertyRelatedByInverseProfilePropertyId(Criteria $c, $con = null)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     ProfilePropertyPeer::addSelectColumns($c);
     $startcol2 = ProfilePropertyPeer::NUM_COLUMNS - ProfilePropertyPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     UserPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS;
     UserPeer::addSelectColumns($c);
     $startcol4 = $startcol3 + UserPeer::NUM_COLUMNS;
     UserPeer::addSelectColumns($c);
     $startcol5 = $startcol4 + UserPeer::NUM_COLUMNS;
     ProfilePeer::addSelectColumns($c);
     $startcol6 = $startcol5 + ProfilePeer::NUM_COLUMNS;
     StatusPeer::addSelectColumns($c);
     $startcol7 = $startcol6 + StatusPeer::NUM_COLUMNS;
     $c->addJoin(ProfilePropertyPeer::CREATED_BY, UserPeer::ID);
     $c->addJoin(ProfilePropertyPeer::UPDATED_BY, UserPeer::ID);
     $c->addJoin(ProfilePropertyPeer::DELETED_BY, UserPeer::ID);
     $c->addJoin(ProfilePropertyPeer::PROFILE_ID, ProfilePeer::ID);
     $c->addJoin(ProfilePropertyPeer::STATUS_ID, StatusPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = ProfilePropertyPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = UserPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getUserRelatedByCreatedBy();
             //CHECKME
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addProfilePropertyRelatedByCreatedBy($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initProfilePropertysRelatedByCreatedBy();
             $obj2->addProfilePropertyRelatedByCreatedBy($obj1);
         }
         $omClass = UserPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj3 = new $cls();
         $obj3->hydrate($rs, $startcol3);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj3 = $temp_obj1->getUserRelatedByUpdatedBy();
             //CHECKME
             if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj3->addProfilePropertyRelatedByUpdatedBy($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj3->initProfilePropertysRelatedByUpdatedBy();
             $obj3->addProfilePropertyRelatedByUpdatedBy($obj1);
         }
         $omClass = UserPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj4 = new $cls();
         $obj4->hydrate($rs, $startcol4);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj4 = $temp_obj1->getUserRelatedByDeletedBy();
             //CHECKME
             if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj4->addProfilePropertyRelatedByDeletedBy($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj4->initProfilePropertysRelatedByDeletedBy();
             $obj4->addProfilePropertyRelatedByDeletedBy($obj1);
         }
         $omClass = ProfilePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj5 = new $cls();
         $obj5->hydrate($rs, $startcol5);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj5 = $temp_obj1->getProfile();
             //CHECKME
             if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj5->addProfileProperty($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj5->initProfilePropertys();
             $obj5->addProfileProperty($obj1);
         }
         $omClass = StatusPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj6 = new $cls();
         $obj6->hydrate($rs, $startcol6);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj6 = $temp_obj1->getStatus();
             //CHECKME
             if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj6->addProfileProperty($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj6->initProfilePropertys();
             $obj6->addProfileProperty($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
Beispiel #10
0
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return    Profile A model object, or null if the key is not found
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `ID`, `NICKNAME`, `EMAIL`, `SF_GUARD_USER_ID` FROM `profile` WHERE `ID` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new Profile();
         $obj->hydrate($row);
         ProfilePeer::addInstanceToPool($obj, (string) $row[0]);
     }
     $stmt->closeCursor();
     return $obj;
 }
//------------------------------------------------------------
$t->diag('ProfilePeer::retrieveByIsDispRegist()');
$profiles = ProfilePeer::retrieveByIsDispRegist();
$t->isa_ok($profiles, 'array', 'retrieveByIsDispRegist() returns an array');
foreach ($profiles as $profile) {
    $t->isa_ok($profile, 'Profile', 'each profile is a Profile');
    $t->cmp_ok($profile->getIsDispRegist(), '===', true, 'Profile::getIsDispRegist() returns true');
}
//------------------------------------------------------------
$t->diag('ProfilePeer::retrieveByIsDispConfig()');
$profiles = ProfilePeer::retrieveByIsDispConfig();
$t->isa_ok($profiles, 'array', 'retrieveByIsDispConfig() returns an array');
foreach ($profiles as $profile) {
    $t->isa_ok($profile, 'Profile', 'each profile is a Profile');
    $t->cmp_ok($profile->getIsDispConfig(), '===', true, 'Profile::getIsDispConfig() returns true');
}
//------------------------------------------------------------
$t->diag('ProfilePeer::retrieveByIsDispSearch()');
$profiles = ProfilePeer::retrieveByIsDispSearch();
$t->isa_ok($profiles, 'array', 'retrieveByIsDispSearch() returns an array');
foreach ($profiles as $profile) {
    $t->isa_ok($profile, 'Profile', 'each profile is a Profile');
    $t->cmp_ok($profile->getIsDispSearch(), '===', true, 'Profile::getIsDispSearch() returns true');
}
//------------------------------------------------------------
$t->diag('ProfilePeer::retrieveByName()');
$profile = ProfilePeer::retrieveByName('self_intro');
$t->isa_ok($profile, 'Profile', 'retrieveByName() returns a Profile');
$t->cmp_ok($profile->getName(), '===', 'self_intro', 'Profile::getName() returns a name');
$t->cmp_ok(ProfilePeer::retrieveByName('unknown'), '===', NULL, 'retrieveByName() returns NULL if name does not exist');
 /**
  * Get the associated Profile object
  *
  * @param      Connection Optional Connection object.
  * @return     Profile The associated Profile object.
  * @throws     PropelException
  */
 public function getProfile($con = null)
 {
     if ($this->aProfile === null && $this->profile_id !== null) {
         // include the related Peer class
         include_once 'lib/model/om/BaseProfilePeer.php';
         $this->aProfile = ProfilePeer::retrieveByPK($this->profile_id, $con);
         /* The following can be used instead of the line above to
         		   guarantee the related object contains a reference
         		   to this object, but this level of coupling
         		   may be undesirable in many circumstances.
         		   As it can lead to a db query with many results that may
         		   never be used.
         		   $obj = ProfilePeer::retrieveByPK($this->profile_id, $con);
         		   $obj->addProfiles($this);
         		 */
     }
     return $this->aProfile;
 }
 public function executeGetclientstatus($request)
 {
     $id = $request->getParameter('id');
     $profile_detail = ProfilePeer::retrieveByPK($id);
     $returnProfile['client_rank_name'] = $profile_detail->getClientRankName();
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     return $this->renderText(json_encode($returnProfile));
 }
Beispiel #14
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = ProfilePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setNickname($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setEmail($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setSfGuardUserId($arr[$keys[3]]);
     }
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = ProfilePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setAgentId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setCreatedAt($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setUpdatedAt($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setDeletedAt($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setCreatedBy($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setUpdatedBy($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setDeletedBy($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setChildUpdatedAt($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setChildUpdatedBy($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setName($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setNote($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setUri($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setUrl($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setBaseDomain($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setToken($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setCommunity($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setLastUriId($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setStatusId($arr[$keys[18]]);
     }
     if (array_key_exists($keys[19], $arr)) {
         $this->setLanguage($arr[$keys[19]]);
     }
 }