Ejemplo n.º 1
0
 public function checkNetwork($request)
 {
     $name = $request->getParameter('name');
     if (!($this->network = LsListTable::getNetworkByDisplayName($name))) {
         $this->forward404();
     }
 }
Ejemplo n.º 2
0
 public function configure()
 {
     $choices = LsListTable::getNetworksForSelect();
     $this->setWidgets(array('email' => new sfWidgetFormInput(array(), array('size' => 30)), 'home_network_id' => new sfWidgetFormSelect(array('choices' => $choices)), 'enable_announcements' => new sfWidgetFormInputCheckBox(), 'enable_notes_notifications' => new sfWidgetFormInputCheckBox(), 'enable_pointers' => new sfWidgetFormInputCheckbox(), 'enable_recent_views' => new sfWidgetFormInputCheckbox(), 'enable_notes_list' => new sfWidgetFormInputCheckbox(), 'ranking_opt_out' => new sfWidgetFormInputCheckbox(), 'watching_opt_out' => new sfWidgetFormInputCheckbox()));
     $this->setValidators(array('email' => new sfValidatorEmail(array('required' => true)), 'home_network_id' => new sfValidatorChoice(array('choices' => array_keys($choices), 'required' => true)), 'enable_announcements' => new sfValidatorBoolean(), 'enable_notes_notifications' => new sfValidatorBoolean(), 'enable_pointers' => new sfValidatorBoolean(), 'enable_recent_views' => new sfValidatorBoolean(), 'enable_notes_list' => new sfValidatorBoolean(), 'ranking_opt_out' => new sfValidatorBoolean(), 'watching_opt_out' => new sfValidatorBoolean()));
     $this->widgetSchema->setLabels(array('home_network_id' => 'Local network', 'enable_announcements' => 'Receive announcements', 'enable_notes_notifications' => 'Receive Notes notifications', 'enable_pointers' => 'Show pointers', 'enable_recent_views' => 'Show Recent Views', 'enable_notes_list' => 'Show Notes list', 'ranking_opt_out' => 'Opt out of rankings', 'watching_opt_out' => 'Opt out of Who\'s Watching'));
     $this->widgetSchema->setHelps(array('email' => 'use this to login and recieve notifications', 'home_network_id' => 'Default network for new entities', 'enable_announcements' => 'send me important announcements about LittleSis', 'enable_notes_notifications' => 'email me when an analyst writes me a note', 'enable_pointers' => 'display helpful hints when available', 'enable_recent_views' => 'show recently viewed entities', 'enable_notes_list' => 'list your notes about the entity, relationship, or list you\'re viewing', 'ranking_opt_out' => 'if checked, your name will not appear in the Analyst Rankings box on the front page', 'watching_opt_out' => 'if checked, your name will not appear in the "Who\'s Watching" box on the lower left of entity profile pages'));
     $this->widgetSchema->setNameFormat('user_settings[%s]');
 }
Ejemplo n.º 3
0
function list_link($list)
{
    $link = '<strong>';
    $admin = '';
    if ($list['is_admin']) {
        $admin = '*';
    }
    $link .= link_to($admin . $list['name'], LsListTable::generateRoute($list)) . '</strong>';
    return $link;
}
Ejemplo n.º 4
0
 public function executeMap($request)
 {
     $this->setResponseFormat(array('xml', 'json'));
     $options = $this->getParams(array('num'));
     $this->data = LsListTable::getEntitiesAndRelsForMap($this->list['id']);
     if ($request->getParameter('format') == "json") {
         return $this->renderText(json_encode($this->data));
     } else {
         return 'Xml';
     }
 }
Ejemplo n.º 5
0
 public function configure()
 {
     $choices = LsListTable::getNetworksForSelect();
     $this->setWidgets(array('home_network_id' => new sfWidgetFormSelect(array('choices' => $choices)), 'name_first' => new sfWidgetFormInput(array(), array('size' => 30)), 'name_last' => new sfWidgetFormInput(array(), array('size' => 30)), 'public_name' => new sfWidgetFormInput(array(), array('size' => 30)), 'email' => new sfWidgetFormInput(array(), array('size' => 30)), 'reason' => new sfWidgetFormTextarea(array(), array('cols' => 50, 'rows' => 3)), 'password1' => new sfWidgetFormInputPassword(array(), array('size' => 30)), 'password2' => new sfWidgetFormInputPassword(array(), array('size' => 30)), 'user_agrees' => new sfWidgetFormInputCheckbox(), 'captcha' => new sfWidgetFormReCaptcha(array('public_key' => sfConfig::get('app_recaptcha_public_key')))));
     $this->setValidators(array('home_network_id' => new sfValidatorChoice(array('choices' => array_keys($choices), 'required' => true)), 'name_last' => new sfValidatorString(array('max_length' => 50)), 'name_first' => new sfValidatorString(array('max_length' => 50)), 'public_name' => new sfValidatorRegex(array('pattern' => '/^[a-z0-9\\.]{4,30}$/i')), 'email' => new sfValidatorEmail(array('required' => true), array('invalid' => 'You must enter a valid email address')), 'reason' => new sfValidatorString(array('required' => true), array('required' => 'Who are you and why are you signing up?')), 'password1' => new sfValidatorRegex(array('pattern' => '/^[a-z0-9]{6,20}$/i')), 'password2' => new sfValidatorString(array(), array('required' => 'You must enter the password twice')), 'user_agrees' => new sfValidatorBoolean(array('required' => true), array('required' => 'You must accept the user agreement')), 'captcha' => new sfValidatorReCaptcha(array('private_key' => sfConfig::get('app_recaptcha_private_key')), array('invalid' => 'You didn\'t pass the spam test!'))));
     $this->validatorSchema['captcha']->addMessage('captcha', 'You didn\'t pass the spam test!');
     $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('password1', sfValidatorSchemaCompare::EQUAL, 'password2'), array(), array('invalid' => 'You must enter the same password twice'));
     sfLoader::loadHelpers(array('Helper', 'Tag', 'Url'));
     $this->widgetSchema->setLabels(array('home_network_id' => 'Local network', 'name_first' => 'First name', 'name_last' => 'Last name', 'reason' => 'A little about you and why you\'re signing up', 'analyst_reason' => 'Why you want to be an ' . link_to('analyst', '@howto'), 'public_name' => 'Public username', 'password1' => 'Password', 'password2' => 'Password (again)', 'user_agrees' => 'Terms of use', 'captcha' => 'Spam test'));
     $this->widgetSchema->setNameFormat('user[%s]');
     $this->validatorSchema->setOption('allow_extra_fields', true);
     $this->validatorSchema->setOption('filter_extra_fields', false);
 }
Ejemplo n.º 6
0
 public function executeMenu()
 {
     $this->items = array();
     if ($this->getUser()->isAuthenticated() && $this->getUser()->getGuardUser()) {
         $name = $this->getUser()->getGuardUser()->getProfile()->public_name;
         $network_name = LsListTable::getNameById(sfGuardUserTable::getHomeNetworkId());
         $network_path = LsListTable::getDisplayNameById(sfGuardUserTable::getHomeNetworkId());
         $this->items[$name]['highlighted'] = true;
         $this->items[$name]['url'] = 'home/notes';
         $this->items[$name]['items'][$this->getContext()->getI18N()->__('Notes')] = 'home/notes';
         $this->items[$name]['items'][$this->getContext()->getI18N()->__('Groups')] = 'home/groups';
         $this->items[$name]['items'][$this->getContext()->getI18N()->__('Edits')] = 'home/modifications';
         $this->items[$name]['items'][$this->getContext()->getI18N()->__('Maps')] = 'home/maps';
         $this->items[$name]['items']['divider1'] = 'divider';
         $this->items[$name]['items'][$network_name] = '@localHome?name=' . $network_path;
         $this->items[$name]['items']['divider2'] = 'divider';
         $this->items[$name]['items'][$this->getContext()->getI18N()->__('Settings')] = 'home/settings';
         $this->items[$name]['items'][$this->getContext()->getI18N()->__('Logout')] = '@sf_guard_signout';
         //recent views
         if ($this->getUser()->getGuardUser()->getProfile()->enable_recent_views && ($entityIds = $this->getUser()->getAttribute('viewed_entity_ids'))) {
             $this->items[$this->getContext()->getI18N()->__('Recent')] = array('url' => null, 'highlighted' => true, 'items' => array());
             //flip entity ids from user session
             $flippedEntityIds = array_flip($entityIds);
             $orderedEntities = array();
             //get viewed entities from db
             $entities = LsDoctrineQuery::create()->from('Entity e')->whereIn('e.id', $entityIds)->setHydrationMode(Doctrine::HYDRATE_ARRAY)->execute();
             //order entities
             foreach ($entities as $entity) {
                 $orderedEntities[$flippedEntityIds[$entity['id']]] = $entity;
             }
             ksort($orderedEntities);
             foreach ($orderedEntities as $entity) {
                 $this->items[$this->getContext()->getI18N()->__('Recent')]['items'][$entity['name']] = EntityTable::generateRoute($entity);
             }
         }
     } else {
         if (sfConfig::get('app_login_enabled')) {
             $this->items[$this->getContext()->getI18N()->__("Login")] = array('url' => '@sf_guard_signin');
             $this->items[$this->getContext()->getI18N()->__("Sign Up")] = array('url' => '@join');
         }
     }
     $this->items = array_merge($this->items, array($this->getContext()->getI18N()->__('Explore') => array('items' => array($this->getContext()->getI18N()->__('Maps') => '@maps', $this->getContext()->getI18N()->__('Lists') => 'list/list', $this->getContext()->getI18N()->__('Groups') => '@groups', $this->getContext()->getI18N()->__('Notes') => '@notes', $this->getContext()->getI18N()->__('Users') => '@users', $this->getContext()->getI18N()->__('Edits') => '@edits')), $this->getContext()->getI18N()->__('Add') => null, $this->getContext()->getI18N()->__('Help') => array('items' => array($this->getContext()->getI18n()->__('Search Help Pages') => '@help', $this->getContext()->getI18N()->__('Beginner') => '@beginnerhelp', $this->getContext()->getI18N()->__('Advanced') => '@advancedhelp')), $this->getContext()->getI18N()->__('About') => array('items' => array('LittleSis' => '@about', $this->getContext()->getI18N()->__('Features') => '@features', $this->getContext()->getI18N()->__('Our Team') => '@team', $this->getContext()->getI18N()->__('Blog') => 'http://blog.littlesis.org', $this->getContext()->getI18N()->__('Press') => '@press', $this->getContext()->getI18N()->__('Data API') => 'http://api.littlesis.org', $this->getContext()->getI18N()->__('Source Code') => 'https://github.com/littlesis-org/littlesis', $this->getContext()->getI18N()->__('Disclaimer') => '@disclaimer', $this->getContext()->getI18N()->__('Contact Us') => '@contact'))));
     if (!$this->getUser()->isAuthenticated()) {
         unset($this->items[$this->getContext()->getI18N()->__('About')]['items'][$this->getContext()->getI18N()->__('Blog')]);
         $this->items[$this->getContext()->getI18N()->__('Blog')] = array('url' => 'http://blog.littlesis.org');
     }
     if ($this->getUser()->isAuthenticated()) {
         $this->items[$this->getContext()->getI18N()->__('Add')] = array('items' => array($this->getContext()->getI18N()->__('Person') => 'entity/addPerson', $this->getContext()->getI18N()->__('Organization') => 'entity/addOrg', $this->getContext()->getI18N()->__('List') => 'list/add'));
     }
 }
Ejemplo n.º 7
0
 static function addUris($list)
 {
     if (!$list['id'] || !$list['name']) {
         return null;
     }
     $list['uri'] = LsListTable::getUri($list);
     $list['api_uri'] = self::getUri($list['id']);
     return $list;
 }
Ejemplo n.º 8
0
 public function executeMap($request)
 {
     $this->checkList($request);
     $num = $request->getParameter('num');
     $this->data = json_encode(LsListTable::getEntitiesAndRelsForMap($this->list['id'], $num, array()));
 }
Ejemplo n.º 9
0
<?php

slot('header_text', $network['name']);
slot('header_link', LsListTable::getNetworkInternalUrl($network));
slot('header_subtext', $network['description']);
?>

<?php 
$actions = array('notes' => array('url' => LsListTable::GetNetworkInternalUrl($network, 'notes')), 'analysts' => array('url' => LsListTable::GetNetworkInternalUrl($network, 'analysts')));
?>

<?php 
if ($sf_user->isAuthenticated()) {
    ?>
  <?php 
    if ($sf_user->getGuardUser()->Profile->home_network_id != $network['id']) {
        ?>
    <?php 
        $actions['make this your home network'] = array('url' => 'home/makeHomeNetwork?id=' . $network["id"], 'options' => 'post=true');
        ?>
  <?php 
    }
} else {
    ?>
  <?php 
    $actions['sign up'] = array('url' => 'home/join?network=' . $network["display_name"]);
}
?>

<?php 
slot('header_actions', $actions);
Ejemplo n.º 10
0
<?php

slot('header_text', $list->name);
slot('header_link', $list->getInternalUrl());
slot('share_links', true);
?>

<?php 
if (isset($show_actions) && $show_actions) {
    ?>
  <?php 
    slot('header_actions', array('add member' => array('url' => $list->getInternalUrl('addEntity')), 'edit' => array('url' => $list->getInternalUrl('edit')), 'remove' => array('url' => $list->getInternalUrl('remove'), 'options' => 'post=true confirm=Are you sure you want to remove this list?', 'credential' => 'deleter'), 'add bulk' => array('url' => $list->getInternalUrl('addBulk'), 'credential' => 'bulker'), 'refresh' => array('url' => LsListTable::getInternalUrl($list, 'refresh', array('ref' => $sf_request->getUri())), 'credential' => 'admin')));
}
Ejemplo n.º 11
0
 public function executeEdit($request)
 {
     $id = $request->getParameter('id') ? $request->getParameter('id') : $request->getParameter('entity[id]');
     $this->entity = Doctrine::getTable('Entity')->find($id);
     $this->forward404Unless($this->entity);
     //get networks
     $this->all_network_ids = EntityTable::getNetworkIdsById($id);
     $this->submitted_network_ids = $this->all_network_ids;
     $homeNetworkId = $this->getUser()->getGuardUser()->Profile->home_network_id;
     $this->show_networks = true;
     if ($this->getUser()->hasCredential('admin')) {
         $permittedNetworkIds = LsListTable::getAllNetworkIds();
     } else {
         $permittedNetworkIds = array_unique(array(LsListTable::US_NETWORK_ID, $homeNetworkId));
     }
     $this->permitted_networks = LsDoctrineQuery::create()->from('LsList l')->whereIn('l.id', $permittedNetworkIds)->execute();
     $otherNetworkIds = array_diff($this->all_network_ids, $permittedNetworkIds);
     $this->other_networks = !count($otherNetworkIds) ? array() : LsDoctrineQuery::create()->from('LsList l')->whereIn('l.id', $otherNetworkIds)->execute();
     //get extensions and definitions
     $primary = $this->entity->getPrimaryExtension();
     $this->tier2_defs = ExtensionDefinitionTable::getByTier(2, $primary);
     $this->tier3_defs = ExtensionDefinitionTable::getByTier(3, $primary);
     $this->entity_exts = $this->entity->getExtensions();
     $this->entity_exts_display = $this->entity->getExtensionsForDisplay(true);
     //create entity form
     $this->entity_form = new EntityForm($this->entity);
     //create primary extension form
     $primaryFormClass = $primary . 'Form';
     $this->primary_ext_form = new $primaryFormClass($this->entity->getPrimaryExtensionObject(), null, false);
     //create all other extension forms
     $this->other_ext_forms = array();
     $exts = ExtensionDefinitionTable::getNamesByTier(array(2, 3), $primary, $havingFields = true);
     $objects = $this->entity->getExtensionObjects();
     foreach ($exts as $ext) {
         if ($ext != 'PublicCompany') {
             continue;
         }
         $class = $ext . 'Form';
         if (isset($objects[$ext])) {
             $object = $objects[$ext];
         } else {
             $object = new $ext();
         }
         $this->other_ext_forms[$ext] = new $class($object, null, false);
     }
     //create reference form
     $this->reference_form = new ReferenceForm();
     $this->reference_form->setSelectObject($this->entity);
     //form submission
     if ($request->isMethod('post')) {
         $this->entity_form->bind($request->getParameter('entity'));
         $this->primary_ext_form->bind($request->getParameter('entity'));
         $new_exts = array_keys((array) $request->getParameter('extensions'));
         $old_exts = $this->entity->getExtensions(true);
         $all_exts = array_merge($new_exts, $old_exts);
         foreach ($all_exts as $ext) {
             if ($ext != 'PublicCompany') {
                 continue;
             }
             if (in_array($ext, ExtensionDefinitionTable::$extensionNamesWithFields)) {
                 $this->other_ext_forms[$ext]->bind($request->getParameter('entity'));
             }
         }
         $networkIds = $request->getParameter('network_ids', array());
         $this->submitted_network_ids = $networkIds;
         $this->reference_form->bind($request->getParameter('reference'));
         if ($this->entity_form->isValid() && $this->reference_form->isValid()) {
             //only edit networks if user's home network is not the United States
             if ($this->show_networks) {
                 //save network changes
                 if (!$networkIds) {
                     $request->setError('network_ids', 'You must select at least one network');
                     return sfView::SUCCESS;
                 }
                 $networksToRemove = array_diff($this->all_network_ids, $networkIds);
                 $networksToAdd = array_diff($networkIds, $this->all_network_ids);
                 foreach ($networksToRemove as $networkId) {
                     LsListEntity::removeByListIdAndEntityId($networkId, $this->entity['id']);
                 }
                 foreach ($networksToAdd as $networkId) {
                     LsListEntity::addByListIdAndEntityId($networkId, $this->entity['id']);
                 }
             }
             //save extension changes
             $exts_to_add = array_diff($new_exts, $old_exts);
             $exts_to_remove = array_diff($old_exts, $new_exts);
             foreach ($exts_to_add as $ext) {
                 $this->entity->addExtension($ext);
             }
             foreach ($exts_to_remove as $ext) {
                 $this->entity->removeExtension($ext);
             }
             //save entity and reference
             $this->entity_form->updateObject();
             $this->entity->saveWithRequiredReference($request->getParameter('reference'));
             //clear cache
             $this->clearCache($this->entity);
             //redirect to view
             $this->redirect($this->entity->getInternalUrl());
         }
     }
 }
Ejemplo n.º 12
0
?>
  <br />
  
<?php 
if ($sf_user->hasCredential('bulker')) {
    ?>
  <?php 
    include_partial('list/expertlinks', array('list' => $list));
    ?>
  <br />
  
<?php 
}
?>
  <?php 
include_partial('global/notes', array('record' => $list, 'model' => 'LsList', 'more_uri' => LsListTable::getInternalUrl($list, 'notes')));
end_slot();
?>



<?php 
if ($list->is_admin) {
    ?>
  <em>This list is maintained by admin users. Please 
  <?php 
    echo link_to('contact us', 'home/contact');
    ?>
  if you would like to suggest changes.</em>
  <br />
  <br />
Ejemplo n.º 13
0
<?php

include_partial('global/section', array('title' => 'Expert Tools'));
?>


<div class="padded margin_bottom">
<?php 
echo link_to('match related donors', LsListTable::getInternalUrl($list, 'matchRelated'));
?>
<br>
</div>
Ejemplo n.º 14
0
 /**
  * Generates internal url for any Entity action
  *
  * @return string
  */
 public function getInternalUrl($action = null, array $params = null, $hideParams = false)
 {
     return LsListTable::generateRoute($this, $action, $params, $hideParams);
 }
Ejemplo n.º 15
0
?>

<?php 
slot('header_text', $network['name'] . ' Notes');
slot('header_link', LsListTable::getNetworkInternalUrl($network, 'notes'));
?>

Showing analyst notes in the <strong><?php 
echo network_link($network);
?>
</strong> network. You can filter the note history by entering search terms below.
<br />
<br />

<form action="<?php 
echo url_for(LsListTable::getNetworkInternalUrl($network, 'notes'));
?>
">
<?php 
echo input_tag('query', $sf_request->getParameter('query'));
?>
 
<?php 
echo submit_tag('Search', 'class=button_small');
?>
</form>

<br />
<br />

<?php 
Ejemplo n.º 16
0
 public function executeFindList($request)
 {
     $terms = $request->getParameter('list_terms');
     $terms = preg_replace('/\\s{2,}/', ' ', $terms);
     $terms = explode(' ', $terms);
     //search for query that excludes the current Entity1
     $q = LsListTable::getSimpleSearchQuery($terms);
     $num = $request->getParameter('num', 10);
     $page = $request->getParameter('page', 1);
     $this->list_pager = new LsDoctrinePager($q, $page, $num);
     return $this->renderPartial('operation/listresults');
 }
Ejemplo n.º 17
0
 public function executeJoin($request)
 {
     $userParams = $request->getParameter('user');
     $this->is_invited = false;
     $this->group = $request->getParameter('group');
     if ($this->group && $this->getUser()->isAuthenticated()) {
         $this->redirect('@groupView?name=' . $this->group);
     }
     //if there's an invitation code supplied, it should match an invitation generated by an invite
     if ($code = $request->getParameter('code')) {
         $profile = Doctrine_Query::create()->from('sfGuardUserProfile p')->where('p.invitation_code = ?', $code)->fetchOne();
         if ($profile) {
             $this->is_invited = true;
         }
     }
     if (!$this->is_invited) {
         $profile = new sfGuardUserProfile();
     }
     //if a network name is supplied
     if ($network_name = $request->getParameter('network')) {
         if ($network = LsListTable::getNetworkByDisplayName($network_name)) {
             $profile->home_network_id = $network["id"];
         }
     }
     $this->user_form = new UserJoinForm($profile);
     $this->profile = $profile;
     //if form is posted, validate
     if ($request->isMethod('post')) {
         //bind request params to form
         $captcha = array('recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'), 'recaptcha_response_field' => $request->getParameter('recaptcha_response_field'));
         $userParams = array_merge($userParams, array('captcha' => $captcha));
         $this->user_form->bind($userParams);
         //if public_name is valid, check that it's unique
         $errors = $this->user_form->getErrorSchema()->getErrors();
         if (!isset($errors['public_name'])) {
             $q = LsDoctrineQuery::create()->from('sfGuardUserProfile p')->where('p.public_name LIKE ?', $userParams['public_name']);
             if (in_array($userParams['public_name'], sfGuardUserProfileTable::$prohibitedPublicNames) || $q->count()) {
                 $validatorSchema = $this->user_form->getValidatorSchema();
                 $validatorSchema['public_name']->setMessage('invalid', 'Sorry, the public name you chose is already taken!');
                 $this->user_form->getErrorSchema()->addError(new sfValidatorError($validatorSchema['public_name'], 'invalid'), 'public_name');
             }
         }
         //look for user with duplicate email
         $q = LsDoctrineQuery::create()->from('sfGuardUserProfile p')->where('REPLACE(p.email, \'.\', \'\') = REPLACE(?, \'.\', \'\')', $userParams['email']);
         //if user was invited, the duplicate user shouldn't have the same code
         //if ($code)
         //{
         //  $q->addWhere('p.invitation_code <> ?', $code);
         //}
         if ($q->count()) {
             $request->setError('email', 'There is already a user with that email');
         }
         //proceed if there are no errors
         if ($this->user_form->isValid() && !$request->hasErrors()) {
             //if user is invited, consider user confirmed
             if ($this->is_invited) {
                 $user = $profile->User;
                 $user->is_active = true;
                 $profile->invitation_code = null;
                 $profile->is_visible = true;
                 $profile->is_confirmed = true;
             } else {
                 $user = new sfGuardUser();
                 //auto-approve?
                 $user->is_active = sfConfig::get('app_accounts_auto_approve') ? true : false;
             }
             $db = Doctrine_Manager::connection();
             try {
                 $db->beginTransaction();
                 //save submitted email as password
                 $user->username = $userParams['email'];
                 $user->algorithm = 'sha1';
                 $user->setPassword($userParams['password1']);
                 if (!$user->hasPermission('contributor')) {
                     $user->addPermissionByName('contributor');
                 }
                 if (!$user->hasPermission('editor')) {
                     $user->addPermissionByName('editor');
                 }
                 $user->save();
                 //save submitted profile fields
                 $profile->user_id = $user->id;
                 $profile->name_first = $userParams['name_first'];
                 $profile->name_last = $userParams['name_last'];
                 $profile->email = $userParams['email'];
                 $profile->reason = $userParams['reason'];
                 $profile->analyst_reason = $userParams['analyst_reason'];
                 $profile->public_name = $userParams['public_name'];
                 $profile->home_network_id = $userParams['home_network_id'];
                 //if not invited, generate code for email confirmation
                 if (!$this->is_invited) {
                     $code = substr(sha1($profile->email . time()), 0, 20);
                     $profile->confirmation_code = $code;
                 }
                 $profile->save();
                 //add user to group, if requested
                 if ($this->group) {
                     $db = Doctrine_Manager::connection();
                     $sql = 'SELECT id FROM sf_guard_group WHERE name = ?';
                     $stmt = $db->execute($sql, array($this->group));
                     if ($groupId = $stmt->fetch(PDO::FETCH_COLUMN)) {
                         $ug = new sfGuardUserGroup();
                         $ug->user_id = $user->id;
                         $ug->group_id = $groupId;
                         $ug->is_owner = 0;
                         $ug->save();
                     }
                 }
                 //send email to notify administrator of new account creation
                 $mailBody = $this->getPartial('accountcreatenotify', array('user' => $user, 'analyst' => $userParams['analyst_reason'], 'group' => $this->group));
                 if ($this->is_invited) {
                     $subject = 'LittleSis account invitation accepted by ' . $userParams['name_first'] . ' ' . $userParams['name_last'];
                 } else {
                     $subject = 'LittleSis account ' . ($user->is_active ? 'created' : 'requested') . ' by ' . $userParams['name_first'] . ' ' . $userParams['name_last'];
                 }
                 $mailer = new Swift(new Swift_Connection_NativeMail());
                 $message = new Swift_Message($subject, $mailBody, 'text/plain');
                 $address = new Swift_Address(sfConfig::get('app_mail_join_sender_address'), sfConfig::get('app_mail_join_sender_name'));
                 $mailer->send($message, sfConfig::get('app_mail_join_sender_address'), $address);
                 $mailer->disconnect();
                 //notify user that the account has been created/requested
                 $subject = $user->is_active ? 'Welcome to LittleSis!' : 'Your request to become a LittleSis analyst';
                 $mailBody = $this->getPartial($user->is_active ? 'accountcreatereceipt' : 'accountrequestreceipt', array('user' => $user, 'password' => $userParams['password1'], 'is_invited' => $this->is_invited));
                 $mailer = new Swift(new Swift_Connection_NativeMail());
                 $message = new Swift_Message('Welcome to LittleSis!', $mailBody, 'text/plain');
                 $address = new Swift_Address(sfConfig::get('app_mail_join_sender_address'), sfConfig::get('app_mail_join_sender_name'));
                 $mailer->send($message, $profile->email, $address);
                 $mailer->disconnect();
                 //if invited, sign in user and record login time
                 if ($this->is_invited) {
                     // signin user
                     $this->getUser()->setAttribute('user_id', $user->id, 'sfGuardSecurityUser');
                     $this->getUser()->setAuthenticated(true);
                     $this->getUser()->clearCredentials();
                     $this->getUser()->addCredentials($user->getAllPermissionNames());
                     // save last login
                     $user->last_login = date('Y-m-d H:i:s');
                     $user->save();
                 }
                 //commit changes
                 $db->commit();
             } catch (Exception $e) {
                 $db->rollback();
                 throw $e;
             }
             //redirect to requested or joined page
             if ($user->is_active) {
                 $this->redirect('home/joined' . ($this->is_invited ? '?conf=1' : ''));
             } else {
                 $this->redirect('home/requested');
             }
         }
     }
 }
Ejemplo n.º 18
0
<?php

$baseHref = '#';
$tabs = array('Members' => array('url' => $list->getInternalUrl('members'), 'href' => $baseHref . 'members', 'actions' => array('members')));
?>

<?php 
$personCount = LsListTable::countPersons($list->id);
if ($personCount) {
    ?>
  <?php 
    $tabs['Interlocks'] = array('url' => $list->getInternalUrl('interlocks'), 'href' => $baseHref . 'interlocks', 'actions' => array('interlocks', 'business', 'government', 'otherOrgs'));
    ?>
  <?php 
    $tabs['Giving'] = array('url' => $list->getInternalUrl('giving'), 'href' => $baseHref . 'giving', 'actions' => array('giving'));
    ?>
  <?php 
    if ($personCount <= 500) {
        ?>
    <?php 
        $tabs['Funding'] = array('url' => $list->getInternalUrl('funding'), 'href' => $baseHref . 'funding', 'actions' => array('funding'));
        ?>
  <?php 
    }
}
?>

<?php 
$tabs['Data'] = array('url' => $list->getInternalUrl('data'), 'href' => $baseHref . 'data', 'remote' => false, 'actions' => array('data'));
?>
Ejemplo n.º 19
0
 public function executeSimple($request)
 {
     $page = $request->getParameter('page', 1);
     $num = $request->getParameter('num', 20);
     $terms = $request->getParameter('q', '');
     //networks to search
     $networkIds = (array) $request->getParameter('network_ids');
     //only show network options if user has home network other than United States
     if (count($networkIds)) {
         $this->networks = LsDoctrineQuery::create()->from('LsList l')->whereIn('l.id', $networkIds)->fetchArray();
     } else {
         $networkIds = null;
     }
     if ($this->getUser()->hasCredential('admin') || !sfConfig::get('app_blacklist_search_enabled')) {
         $this->results_pager = EntityTable::getSphinxPager($terms, $page, $num, $networkIds);
     } else {
         $blacklistIds = (array) sfConfig::get('app_blacklist_search_ids');
         $entities = array();
         $result = EntityTable::getSphinxHits($terms, $page, $num, $networkIds);
         if ($result['total_found'] > 0 && isset($result['matches'])) {
             $ids = array_diff(array_keys($result['matches']), $blacklistIds);
             if (count($ids) > 0) {
                 $db = Doctrine_Manager::connection();
                 $sql = 'SELECT e.*, FIELD(e.id, ' . implode(',', $ids) . ') AS field ' . 'FROM entity e WHERE e.id IN (' . implode(',', $ids) . ') AND e.is_deleted = 0 ' . 'ORDER BY field';
                 $stmt = $db->execute($sql);
                 $entities = $stmt->fetchAll(PDO::FETCH_ASSOC);
             }
         }
         $pager = new LsDoctrinePager($entities, $page, $num);
         $pager->setNumResults(count($ids));
         $pager->isSubsetWithCount(true);
         $this->results_pager = $pager;
     }
     //search lists
     if (strlen($terms) > 2) {
         $this->lists = LsListTable::getListsFromSphinxSearch($terms, $this->getUser()->hasCredential('admin'));
         // $db = Doctrine_Manager::connection();
         // $sql = 'SELECT l.* FROM ls_list l WHERE l.name LIKE ? AND l.is_deleted = 0 AND l.is_network = 0 ' .
         //        ($this->getUser()->hasCredential('admin') ? '' : 'AND l.is_admin = 0 ') .
         //        'ORDER BY l.name ASC';
         // $stmt = $db->execute($sql, array('%' . $terms . '%'));
         // $this->lists = $stmt->fetchAll(PDO::FETCH_ASSOC);
     }
     //search groups
     if (strlen($terms) > 2) {
         $db = Doctrine_Manager::connection();
         if (sfConfig::get('app_rails_enabled')) {
             $sql = 'SELECT g.* FROM groups g WHERE (g.name LIKE ? OR g.tagline LIKE ? OR g.description LIKE ? OR g.slug LIKE ?) AND g.is_private = 0 ORDER BY g.name ASC';
             $stmt = $db->execute($sql, array('%' . $terms . '%', '%' . $terms . '%', '%' . $terms . '%', '%' . $terms . '%'));
         } else {
             $sql = 'SELECT g.* FROM sf_guard_group g WHERE (g.display_name LIKE ? OR g.name LIKE ? OR g.blurb LIKE ?) AND g.is_working = 1 AND g.is_private = 0 ORDER BY g.display_name ASC';
             $stmt = $db->execute($sql, array('%' . $terms . '%', '%' . $terms . '%', '%' . $terms . '%'));
         }
         $this->groups = $stmt->fetchAll(PDO::FETCH_ASSOC);
     }
     //search campaigns
     if (strlen($terms) > 2 && sfConfig::get('app_rails_enabled')) {
         $db = Doctrine_Manager::connection();
         $sql = 'SELECT c.* FROM campaigns c WHERE (c.name LIKE ? OR c.tagline LIKE ? OR c.description LIKE ? OR c.slug LIKE ?) ORDER BY c.name ASC';
         $stmt = $db->execute($sql, array('%' . $terms . '%', '%' . $terms . '%', '%' . $terms . '%', '%' . $terms . '%'));
         $this->campaigns = $stmt->fetchAll(PDO::FETCH_ASSOC);
     }
 }
Ejemplo n.º 20
0
        ?>
    <?php 
        cache_save();
        ?>
  <?php 
    }
}
?>


<br />
<br />


<?php 
include_partial('global/section', array('title' => 'Analysts In This Network', 'pager' => $user_pager, 'more' => LsListTable::getNetworkInternalUrl($network, 'analysts')));
?>
<div class="padded">
<?php 
foreach ($user_pager->execute() as $user) {
    ?>
  <div style="float: left; padding: .6em; height: 5em; text-align: center;">
    <?php 
    echo user_pic($user);
    ?>
 
    <br />
    <span class="text_small"><?php 
    echo user_link($user);
    ?>
</span>
Ejemplo n.º 21
0
<br />
<br />

<?php 
echo list_link($list);
?>
 &nbsp;&larr;Member&rarr;&nbsp;
<strong>Entity Y</strong> &nbsp;&larr;Relationship&rarr;&nbsp;
<strong>Entity X</strong>

<br />
<br />

<form action="<?php 
echo url_for(LsListTable::getInternalUrl($list, 'networkSearch'));
?>
" method="GET">

<table style="width: auto;">
  <tr>
    <td>Relationship:</td>
    <td>
      <?php 
foreach ($categories as $id => $name) {
    ?>
        <?php 
    echo checkbox_tag('cat_ids[]', $id, in_array($id, explode(',', $cat_ids)));
    echo $name;
    ?>
      <?php 
Ejemplo n.º 22
0
<?php

slot('header_text', $network['name']);
slot('header_link', LsListTable::getNetworkInternalUrl($network));
?>

<?php 
include_partial('global/section', array('title' => 'Analysts in this Network', 'pager' => $user_pager));
?>

<div class="padded">
<?php 
foreach ($user_pager->execute() as $user) {
    ?>
  <div style="float: left; padding: .6em; height: 5em; text-align: center;">
    <?php 
    echo user_pic($user);
    ?>
 
    <br />
    <span class="text_small"><?php 
    echo user_link($user);
    ?>
</span>
  </div>
<?php 
}
?>
</div>
Ejemplo n.º 23
0
<?php

include_partial('global/section', array('title' => 'Lists', 'pointer' => 'Analyst-created lists of people and orgs', 'action' => array('text' => 'add', 'url' => EntityTable::getInternalUrl($entity, 'addList'))));
?>

<div class="padded">
<?php 
foreach (EntityTable::getLsListsById($entity['id']) as $list) {
    ?>
  <?php 
    if (!$list['is_admin'] || $sf_user->hasCredential('editor')) {
        ?>
    <strong><?php 
        echo link_to(($list['is_admin'] ? '*' : '') . $list['name'], LsListTable::getInternalUrl($list));
        ?>
</strong>    
    <?php 
        if ($list['rank']) {
            ?>
      [#<?php 
            echo $list['rank'];
            ?>
]
    <?php 
        }
        ?>
    <?php 
        if ($sf_user->hasCredential('editor') && !$list['is_admin'] || $sf_user->hasCredential('admin')) {
            ?>
      <span class="text_small">
       (<?php