Beispiel #1
0
 /**
  * Constructor. Only run once for singleton object.
  */
 protected function __construct()
 {
     // XXX: there should be an easier way to do this.
     $user = new User();
     $this->conn = $user->getDatabaseConnection();
     $user->free();
     unset($user);
 }
Beispiel #2
0
 function getUserMembers()
 {
     // XXX: cache this
     $user = new User();
     if (common_config('db', 'quote_identifiers')) {
         $user_table = '"user"';
     } else {
         $user_table = 'user';
     }
     $qry = 'SELECT id ' . 'FROM ' . $user_table . ' JOIN group_member ' . 'ON ' . $user_table . '.id = group_member.profile_id ' . 'WHERE group_member.group_id = %d ';
     $user->query(sprintf($qry, $this->id));
     $ids = array();
     while ($user->fetch()) {
         $ids[] = $user->id;
     }
     $user->free();
     return $ids;
 }
Beispiel #3
0
/**
 * broadcast a notice to all subscribers with SMS notification on
 *
 * This function sends SMS messages to all users who have sms addresses;
 * have sms notification on; and have sms enabled for this particular
 * subscription.
 *
 * @param Notice $notice The notice to broadcast
 *
 * @return success flag
 */
function mail_broadcast_notice_sms($notice)
{
    // Now, get users subscribed to this profile
    $user = new User();
    $UT = common_config('db', 'type') == 'pgsql' ? '"user"' : 'user';
    $user->query('SELECT nickname, smsemail, incomingemail ' . "FROM {$UT} JOIN subscription " . "ON {$UT}.id = subscription.subscriber " . 'WHERE subscription.subscribed = ' . $notice->profile_id . ' ' . "AND {$UT}.smsemail IS NOT null " . "AND {$UT}.smsnotify = 1 " . 'AND subscription.sms = 1 ');
    while ($user->fetch()) {
        common_log(LOG_INFO, 'Sending notice ' . $notice->id . ' to ' . $user->smsemail, __FILE__);
        $success = mail_send_sms_notice_address($notice, $user->smsemail, $user->incomingemail);
        if (!$success) {
            // XXX: Not sure, but I think that's the right thing to do
            common_log(LOG_WARNING, 'Sending notice ' . $notice->id . ' to ' . $user->smsemail . ' FAILED, cancelling.', __FILE__);
            return false;
        }
    }
    $user->free();
    unset($user);
    return true;
}
 public function testUpdateSupportsNullSetting()
 {
     $user = new User();
     $user->name = 'jon';
     $user->loginname = 'jwage';
     $user->password = '******';
     $user->save();
     $id = $user->id;
     $user->free();
     $q = Doctrine_Query::create()->update('User u')->set('u.name', 'NULL')->where('u.id = ?', $id);
     $this->assertEqual($q->getSqlQuery(), 'UPDATE entity SET name = NULL WHERE (id = ? AND (type = 0))');
     $q->execute();
     $user = Doctrine_Query::create()->from('User u')->where('u.id = ?', $id)->fetchOne();
     $this->assertEqual($user->name, '');
 }
Beispiel #5
0
 public function testReplaceReplacesAndNotInsertsNewRecord()
 {
     $users = Doctrine_Query::create()->from('User u');
     $count = $users->count();
     $user = new User();
     $user->name = 'jon wage2';
     $user->loginname = 'jwage2';
     $user->save();
     $id = $user->id;
     $user->free();
     $count++;
     $users = Doctrine_Query::create()->from('User u')->execute();
     $this->assertEqual($users->count(), $count);
     $users->free();
     $user = new User();
     $user->assignIdentifier($id);
     $user->name = 'jon wage changed';
     $user->loginname = 'jwage2';
     $user->replace();
     $user->free();
     $users = Doctrine_Query::create()->from('User u')->execute();
     $this->assertEqual($users->count(), $count);
     $users->free();
     $user = Doctrine_Query::create()->from('User u')->where('u.loginname = ?', 'jwage2')->fetchOne();
     $this->assertEqual($user->name, 'jon wage changed');
     $user->name = 'jon wage changed2';
     $user->replace();
     $user = Doctrine_Query::create()->from('User u')->where('u.loginname = ?', 'jwage2')->fetchOne();
     $this->assertEqual($user->name, 'jon wage changed2');
 }
Beispiel #6
0
class TestUserForm extends UserForm
{
  public function configure()
  {
    parent::configure();
    unset($this['test']);
  }
}

$user = new User();
$user->username = '******';
$user->password = '******';
$user->test = 'test';
$user->save();
$user->free();
unset($user);

$user = Doctrine_Core::getTable('User')->findOneByUsername('nullvaluetest');
$userForm = new TestUserForm($user);
$userForm->bind(array('id' => $user->id, 'username' => 'nullvaluetest', 'password' => 'changeme2'));
if ($userForm->isValid())
{
  $userForm->save();
}

$user->free();
unset($user);

$user = Doctrine_Core::getTable('User')->findOneByUsername('nullvaluetest');
$t->is($user->toArray(), array('id' => 1, 'username' => 'nullvaluetest', 'password' => 'b0660f0b8b989971524762330aea5449', 'test' => 'test'));
Beispiel #7
0
 function getSubscribedUsers()
 {
     $user = new User();
     if (common_config('db', 'quote_identifiers')) {
         $user_table = '"user"';
     } else {
         $user_table = 'user';
     }
     $qry = 'SELECT id ' . 'FROM ' . $user_table . ' JOIN subscription ' . 'ON ' . $user_table . '.id = subscription.subscriber ' . 'WHERE subscription.subscribed = %d ';
     $user->query(sprintf($qry, $this->profile_id));
     $ids = array();
     while ($user->fetch()) {
         $ids[] = $user->id;
     }
     $user->free();
     return $ids;
 }
 public function testNullAggregateIsSet()
 {
     $user = new User();
     $user->name = 'jon';
     $user->loginname = 'jwage';
     $user->Phonenumber[0]->phonenumber = new Doctrine_Expression('NULL');
     $user->save();
     $id = $user->id;
     $user->free();
     $query = Doctrine_Query::create()->select('u.*, p.*, SUM(p.phonenumber) summ')->from('User u')->leftJoin('u.Phonenumber p')->where('u.id = ?', $id);
     $users = $query->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     $this->assertTrue(array_key_exists('summ', $users[0]));
 }
Beispiel #9
0
 if ($do_contact->getNumRows()) {
     if ($do_contact->picture != '') {
         $thumb_name = $_SERVER['DOCUMENT_ROOT'] . '/dbimage/thumbnail/' . $do_contact->picture;
         if (file_exists($thumb_name)) {
             $contact_picture = "/dbimage/thumbnail/" . $do_contact->picture;
         } else {
             $contact_picture = "/images/empty_avatar.gif";
         }
     } else {
         $contact_picture = '/images/empty_avatar.gif';
     }
     $contact_id = $do_contact->idcontact;
 }
 $do_user = new User();
 $username = $do_user->getUserLoginId($_SESSION['do_coworker']->idcoworker);
 $do_user->free();
 echo '<div class="feed_user_pic" style="overflow:hidden;">';
 $user_first_name = $_SESSION['do_coworker']->firstname;
 // echo '<a href="/profile/'.$user_first_name[0].'"> <img height="100%" alt="" src='.$contact_picture.' > </a>';
 echo '<a href="' . $GLOBALS['cfg_ofuz_site_http_base'] . 'profile/' . $username . '" target="_blank"><img height="100%" alt="" src=' . $contact_picture . '</a>';
 echo '</div>';
 echo $_SESSION['do_coworker']->firstname, ' ', $_SESSION['do_coworker']->lastname, '&nbsp;';
 /** echo '<span>
     '._('You have shared').' '.$no_cont_shared.' '._('contacts').'
     </span>
     &nbsp;&nbsp;';
     echo '<span>'
     .$no_cont_shared_by_co_worker.' '. _('contacts are shared by').' '.$_SESSION['do_User']->getFullName($_SESSION['do_coworker']->idcoworker).
     '</span>';
     *
     */
Beispiel #10
0
 /**
  * Method to send the email
  * @param $idinvoice -- INT
  * @param $idcontact -- INT
  * @param $iduser -- INT
  * @param $recurrent -- Boolean
  */
 function sendInvoiceByEmail($idinvoice, $idcontact, $iduser, $recurrent = false)
 {
     $do_contact = new Contact();
     $do_user_rel = new UserRelations();
     $this->getId($idinvoice);
     if ($recurrent === true) {
         $this->sessionPersistent("do_invoice", "index.php", OFUZ_TTL);
     }
     $do_contact->getId($idcontact);
     $contact_name = $do_contact->firstname . ' ' . $do_contact->lastname;
     $do_contact_email = $do_contact->getChildContactEmail();
     $contact_email = $do_contact_email->getDefaultEmail();
     $do_user_detail = new User();
     $do_user_detail->getId($iduser);
     if ($contact_email) {
         $total_due = $this->amt_due;
         $total_due = $this->viewAmount($total_due);
         if ($recurrent) {
             $do_rec_invoice = new RecurrentInvoice();
             $idrec = $do_rec_invoice->checkIfInvoiceIsInRecurrent($idinvoice);
             if ($idrec) {
                 $email_template = new EmailTemplate("ofuz_send_recurrent_invoice");
                 $do_rec_invoice->getId($idrec);
                 $next_due_date = $do_rec_invoice->nextdate;
                 $recurrence = $do_rec_invoice->recurrence;
                 $recurrence_type = $do_rec_invoice->recurrence_type;
             } else {
                 $email_template = new EmailTemplate("ofuz_send_invoice");
             }
         } else {
             $email_template = new EmailTemplate("ofuz_send_invoice");
         }
         if ($this->status == 'Quote') {
             $email_template = new EmailTemplate("ofuz_send_quote");
         }
         $email_template->setSenderName($do_user_detail->getFullName());
         $email_template->setSenderEmail($do_user_detail->email);
         $signature = $do_user_detail->company . '<br />' . $do_user_detail->getFullName();
         $description = $this->description;
         $invoice_url = $GLOBALS['cfg_ofuz_site_https_base'] . 'inv/' . $do_user_rel->encrypt($idinvoice) . '/' . $do_user_rel->encrypt($idcontact);
         $email_data = array('name' => $contact_name, 'sender' => $do_user_detail->getFullName(), 'company' => $do_user_detail->company, 'description' => $description, 'invoice_url' => $invoice_url, 'num' => $this->num, 'signature' => $signature, 'amount' => $total_due, 'recurrence' => $recurrence, 'recurrence_type' => $recurrence_type, 'next_due_date' => $next_due_date);
         $emailer = new Radria_Emailer();
         $emailer->setEmailTemplate($email_template);
         $emailer->mergeArray($email_data);
         $emailer->addTo($contact_email);
         //attachment starts
         // Some bug in the PDF part it does not send the correct PDF as it says due amt is 0. Happens for the cron to send recurrent inv
         //echo '<br />Calling Method generatePDFInvoice().....<br />';
         // This is fixed
         $this->generatePDFInvoice($invoice_url);
         $fpdf_file_name = $this->getEncryptedFileName("pdf");
         $pdfFilePath = "invoice_pdf/{$fpdf_file_name}";
         $pdfFile = file_get_contents($pdfFilePath);
         $at = $emailer->createAttachment($pdfFile);
         $at->type = 'image/pdf';
         $at->disposition = Zend_Mime::DISPOSITION_INLINE;
         $at->encoding = Zend_Mime::ENCODING_BASE64;
         $at->filename = $fpdf_file_name;
         //attachment ends
         $emailer->send();
         if ($this->status == 'New') {
             $this->status = 'Sent';
             $this->update();
         }
         if ($recurrent) {
             $q = new sqlQuery($this->getDbCon());
             $q->query("update invoice set status = 'Sent' where idinvoice = " . $idinvoice . " Limit 1");
             $q->free();
         }
         $_SESSION['in_page_message'] = "client_invoice_sent";
         $_SESSION['in_page_message_data']['contact_email'] = $contact_email;
     } else {
         $_SESSION['in_page_message'] = "invoice_client_email_not_found";
     }
     $do_user_detail->free();
 }
Beispiel #11
0
/**
 * broadcast a notice to all subscribers and reply recipients
 *
 * This function will send a notice to all subscribers on the local server
 * who have Jabber addresses, and have Jabber notification enabled, and
 * have this subscription enabled for Jabber. It also sends the notice to
 * all recipients of @-replies who have Jabber addresses and Jabber notification
 * enabled. This is really the heart of Jabber distribution in Laconica.
 *
 * @param Notice $notice The notice to broadcast
 *
 * @return boolean success flag
 */
function jabber_broadcast_notice($notice)
{
    if (!common_config('xmpp', 'enabled')) {
        return true;
    }
    $profile = Profile::staticGet($notice->profile_id);
    if (!$profile) {
        common_log(LOG_WARNING, 'Refusing to broadcast notice with ' . 'unknown profile ' . common_log_objstring($notice), __FILE__);
        return false;
    }
    $msg = jabber_format_notice($profile, $notice);
    $entry = jabber_format_entry($profile, $notice);
    $profile->free();
    unset($profile);
    $sent_to = array();
    $conn = jabber_connect();
    // First, get users to whom this is a direct reply
    $user = new User();
    $UT = common_config('db', 'type') == 'pgsql' ? '"user"' : 'user';
    $user->query("SELECT {$UT}.id, {$UT}.jabber " . "FROM {$UT} JOIN reply ON {$UT}.id = reply.profile_id " . 'WHERE reply.notice_id = ' . $notice->id . ' ' . "AND {$UT}.jabber is not null " . "AND {$UT}.jabbernotify = 1 " . "AND {$UT}.jabberreplies = 1 ");
    while ($user->fetch()) {
        common_log(LOG_INFO, 'Sending reply notice ' . $notice->id . ' to ' . $user->jabber, __FILE__);
        $conn->message($user->jabber, $msg, 'chat', null, $entry);
        $conn->processTime(0);
        $sent_to[$user->id] = 1;
    }
    $user->free();
    // Now, get users subscribed to this profile
    $user = new User();
    $user->query("SELECT {$UT}.id, {$UT}.jabber " . "FROM {$UT} JOIN subscription " . "ON {$UT}.id = subscription.subscriber " . 'WHERE subscription.subscribed = ' . $notice->profile_id . ' ' . "AND {$UT}.jabber is not null " . "AND {$UT}.jabbernotify = 1 " . 'AND subscription.jabber = 1 ');
    while ($user->fetch()) {
        if (!array_key_exists($user->id, $sent_to)) {
            common_log(LOG_INFO, 'Sending notice ' . $notice->id . ' to ' . $user->jabber, __FILE__);
            $conn->message($user->jabber, $msg, 'chat', null, $entry);
            // To keep the incoming queue from filling up,
            // we service it after each send.
            $conn->processTime(0);
            $sent_to[$user->id] = 1;
        }
    }
    // Now, get users who have it in their inbox because of groups
    $user = new User();
    $user->query("SELECT {$UT}.id, {$UT}.jabber " . "FROM {$UT} JOIN notice_inbox " . "ON {$UT}.id = notice_inbox.user_id " . 'WHERE notice_inbox.notice_id = ' . $notice->id . ' ' . 'AND notice_inbox.source = 2 ' . "AND {$UT}.jabber is not null " . "AND {$UT}.jabbernotify = 1 ");
    while ($user->fetch()) {
        if (!array_key_exists($user->id, $sent_to)) {
            common_log(LOG_INFO, 'Sending notice ' . $notice->id . ' to ' . $user->jabber, __FILE__);
            $conn->message($user->jabber, $msg, 'chat', null, $entry);
            // To keep the incoming queue from filling up,
            // we service it after each send.
            $conn->processTime(0);
            $sent_to[$user->id] = 1;
        }
    }
    $user->free();
    return true;
}
     }
 }
 // User setting data ends here
 if (isset($_SESSION['do_invoice']->payment_selection)) {
     if ($_SESSION['do_invoice']->payment_selection == 'authorized.net') {
         if (!empty($_SESSION['do_invoice']->authnet_login) && !empty($_SESSION['do_invoice']->authnet_merchant_id)) {
             $payment_mode = true;
         }
     }
 } else {
     if (!empty($_SESSION['do_invoice']->authnet_login) && !empty($_SESSION['do_invoice']->authnet_merchant_id)) {
         $payment_mode = true;
     }
 }
 if ($payment_mode == true) {
     $do_user_detail->free();
     $arr_user_info = $do_contact->getContactInfo_For_Invoice($do_recurrent->idcontact);
     $inv_info_arr = array();
     $inv_info_arr['description'] = $_SESSION['do_invoice']->description;
     $inv_info_arr['inv_num'] = $_SESSION['do_invoice']->num;
     $cc_number = $do_recurrent_cc->CCDecrypt($do_recurrent->cc_num);
     $payment_type = $do_recurrent->cc_type;
     $expire_year = $do_recurrent->cc_exp_year;
     $expire_month = $do_recurrent->cc_exp_mon;
     /* @param true = test mode
          @param false = non test mode i.e live  
        */
     $payment = new Authnet(false, $arr_user_info, $_SESSION['do_invoice']->authnet_login, $_SESSION['do_invoice']->authnet_merchant_id, $inv_info_arr);
     $cc_msg = $payment->validateCreditCard($cc_number, $payment_type, "", $expire_year, $expire_month, false);
     //echo '<br />'.$cc_msg;
     if ($cc_msg == "") {
Beispiel #13
0
 function blowSubsCache($blowLast = false)
 {
     $cache = common_memcache();
     if ($cache) {
         $user = new User();
         $UT = common_config('db', 'type') == 'pgsql' ? '"user"' : 'user';
         $user->query('SELECT id ' . "FROM {$UT} JOIN subscription ON {$UT}.id = subscription.subscriber " . 'WHERE subscription.subscribed = ' . $this->profile_id);
         while ($user->fetch()) {
             $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
             if ($blowLast) {
                 $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id . ';last'));
             }
         }
         $user->free();
         unset($user);
     }
 }